Skip to content

Commit

Permalink
feat(log): catch ContractExeException in createShieldedContractParame…
Browse files Browse the repository at this point in the history
…ter (#5660)

* feat(log): catch ContractExeException in createShieldedContractParameters
  • Loading branch information
317787106 authored Jan 11, 2024
1 parent 52b3327 commit f9bab7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions framework/src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,7 @@ private void postSolidityLogContractTrigger(Long blockNum, Long lastSolidityNum)
triggerCapsule.setTriggerName(Trigger.SOLIDITYLOG_TRIGGER_NAME);
EventPluginLoader.getInstance().postSolidityLogTrigger(triggerCapsule);
} else {
// when switch fork, block will be post to triggerCapsuleQueue, transaction may be not found
logger.error("PostSolidityLogContractTrigger txId = {} not contains transaction.",
triggerCapsule.getTransactionId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import org.tron.core.config.args.Args;
import org.tron.core.db.Manager;
import org.tron.core.exception.BadItemException;
import org.tron.core.exception.ContractExeException;
import org.tron.core.exception.ContractValidateException;
import org.tron.core.exception.ItemNotFoundException;
import org.tron.core.exception.NonUniqueObjectException;
Expand Down Expand Up @@ -2475,7 +2476,7 @@ public void createShieldedContractParameters(
ShieldedTRC20Parameters shieldedTRC20Parameters = wallet
.createShieldedContractParameters(request);
responseObserver.onNext(shieldedTRC20Parameters);
} catch (ZksnarkException | ContractValidateException e) {
} catch (ZksnarkException | ContractValidateException | ContractExeException e) {
responseObserver.onError(getRunTimeException(e));
logger.info("createShieldedContractParameters: {}", e.getMessage());
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.tron.core.capsule.utils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -23,4 +25,14 @@ public void testGetRLPData() {
Assert.assertEquals(new String(rlpList.getRLPData()), "rlpData");
}

@Test
public void testToBytes()
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Method method = RLP.class.getDeclaredMethod("toBytes", Object.class);
method.setAccessible(true);

byte[] aBytes = new byte[10];
byte[] bBytes = (byte[]) method.invoke(RLP.class, aBytes);
Assert.assertArrayEquals(aBytes, bBytes);
}
}

0 comments on commit f9bab7a

Please sign in to comment.