add debug port for cp

This commit is contained in:
CaiHQ 2022-09-02 21:00:02 +08:00
parent 0aac9d16d9
commit 0da9d88173
2 changed files with 20 additions and 1 deletions

View File

@ -41,6 +41,7 @@ public class Contract extends SM2Verifiable implements Serializable {
private YjsType yjsType;
private SerializableJson createParam;
private int remoteDebugPort = 0;
public int getShardingId() {
return this.shardingId;
@ -232,9 +233,17 @@ public class Contract extends SM2Verifiable implements Serializable {
createParam = new SerializableJson(ele);
}
public void setRemoteDebugPort(int port) {
remoteDebugPort = port;
}
public JsonElement getCreateParam() {
if (createParam != null)
return createParam.getJsonElement();
return null;
}
public int getRemoteDebugPort() {
return remoteDebugPort;
}
}

View File

@ -20,6 +20,16 @@ public class SM2UtilTest {
"{\"publicKey\":\"0442e39c0b1623e6f95ef896d37f41aa3cd98fbc3aea71250eedba4335c6c3aff51b5fa2352f920d1063b50a30738427c18375df886985a63e0f496293fdad22a8\",\"privateKey\":\"b7e504cf951792554bf4a9874be37cb1279d38939444388e2046ee9603b4f0c4\"}";
SM2KeyPair keyPair = SM2KeyPair.fromJson(keyPairStr);
@Test
public void loadKey() throws Exception {
String keyStr = "{\"privateKey\": \"b4ab74a0d8691fc45fd214bdaf45b1dc6ac288a93d1518599fc824ab29310a1a\",\n" +
" \"publicKey\": \"04fef570617a3a2dfba6a4dd25050919266735f683f69aee8df4cd600f34b7440a26e90af3b92b63bad7c013f32c2665599ddde33c87736efa667eb027cdd8572f\"\n" +
" }";
SM2KeyPair keyPair = SM2KeyPair.fromJson(keyStr);
byte[] result = SM2Util.sign(keyPair.getPrivateKeyParameter(), "abc".getBytes());
System.out.println(result.length);
}
@Test
public void verify2() {
String toVerify = "GeneralContract|plainTextTransmission|{\"ledger\":\"test\",\"data\":\"上链信息为json格式\"}|04398dfde44290595cd098cd2f904b36367c69f9011719d43fb0955f823cf1386764769bc7c0a5649dcb316d552998a5c106afd268d9db8b6482ce527544a7bd15";
@ -133,7 +143,7 @@ public class SM2UtilTest {
@Test
public void dosignTest() throws Exception {
String tosign = "action=startContract&script=contract%20shortc%7B%0A%09export%20function%20main(arg)%7B%0A%09%09return%20arg.length%3B%09%0A%09%7D%0A%7D&pubKey=041a3875bb1a8d6acfc1142c60e3cc7c11831d4878c6dbbf9bb0929716d6cf402492b9629a4ced9198ae2c419f8d3d6ae810a431458d38901e5597636b715584d4";
// keyPair = SM2KeyPair.fromJson("{\"privateKey\":\"94728f3d95f19b3b5b11a31fdb603b5b2e8b377d9520d0680ac4f270cc82ec51\",\"publicKey\":\"041a3875bb1a8d6acfc1142c60e3cc7c11831d4878c6dbbf9bb0929716d6cf402492b9629a4ced9198ae2c419f8d3d6ae810a431458d38901e5597636b715584d4\"}");
// keyPair = SM2KeyPair.fromJson("{\"privateKey\":\"94728f3d95f19b3b5b11a31fdb603b5b2e8b377d9520d0680ac4f270cc82ec51\",\"publicKey\":\"041a3875bb1a8d6acfc1142c60e3cc7c11831d4878c6dbbf9bb0929716d6cf402492b9629a4ced9198ae2c419f8d3d6ae810a431458d38901e5597636b715584d4\"}");
keyPair = SM2KeyPair.fromJson("{\"privateKey\":\"589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8\",\"publicKey\":\"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}");
String signature = ByteUtils.toHexString(
SM2Util.sign(