Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion actuator/src/main/java/org/tron/core/utils/ProposalUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
break;
}
case ALLOW_MARKET_TRANSACTION: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)) {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)
|| forkController.pass(ForkBlockVersionEnum.VERSION_4_8_1)) {
throw new ContractValidateException(
"Bad chain parameter id [ALLOW_MARKET_TRANSACTION]");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.tron.core.actuator.utils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

import com.google.protobuf.ByteString;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -11,6 +14,7 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.tron.common.BaseTest;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ForkController;
Expand Down Expand Up @@ -438,9 +442,28 @@ public void validateCheck() {
testAllowTvmCancunProposal();

testAllowTvmBlobProposal();

ThrowingRunnable r0 = () -> ProposalUtil.validator(dynamicPropertiesStore, forkUtils,
ProposalType.ALLOW_MARKET_TRANSACTION.getCode(), 0);
ThrowingRunnable r1 = () -> ProposalUtil.validator(dynamicPropertiesStore, forkUtils,
ProposalType.ALLOW_MARKET_TRANSACTION.getCode(), 1);
ContractValidateException thrown = assertThrows(ContractValidateException.class, r1);
assertEquals("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]", thrown.getMessage());

forkUtils.getManager().getDynamicPropertiesStore().statsByVersion(
ForkBlockVersionEnum.VERSION_4_1.getValue(), stats);
try {
r1.run();
} catch (Throwable e) {
Assert.fail(e.getMessage());
}
thrown = assertThrows(ContractValidateException.class, r0);
assertEquals("This value[ALLOW_MARKET_TRANSACTION] is only allowed to be 1",
thrown.getMessage());
testAllowTvmSelfdestructRestrictionProposal();

thrown = assertThrows(ContractValidateException.class, r1);
assertEquals("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]", thrown.getMessage());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the boundary version be explicitly set here?

forkUtils.getManager().getDynamicPropertiesStore().statsByVersion(
        ForkBlockVersionEnum.VERSION_4_8_1.getValue(), stats);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


forkUtils.getManager().getDynamicPropertiesStore()
.statsByVersion(ForkBlockVersionEnum.ENERGY_LIMIT.getValue(), stats);
forkUtils.reset();
Expand Down Expand Up @@ -710,7 +733,6 @@ private void testAllowTvmSelfdestructRestrictionProposal() {
"[ALLOW_TVM_SELFDESTRUCT_RESTRICTION] has been valid, no need to propose again",
e.getMessage());
}

}

@Test
Expand Down