|
1 | 1 | package org.tron.core.actuator.utils; |
2 | 2 |
|
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | +import static org.junit.Assert.assertThrows; |
| 5 | + |
3 | 6 | import com.google.protobuf.ByteString; |
4 | 7 | import java.util.ArrayList; |
5 | 8 | import java.util.Arrays; |
|
11 | 14 | import org.junit.Assert; |
12 | 15 | import org.junit.BeforeClass; |
13 | 16 | import org.junit.Test; |
| 17 | +import org.junit.function.ThrowingRunnable; |
14 | 18 | import org.tron.common.BaseTest; |
15 | 19 | import org.tron.common.utils.ByteArray; |
16 | 20 | import org.tron.common.utils.ForkController; |
@@ -438,9 +442,28 @@ public void validateCheck() { |
438 | 442 | testAllowTvmCancunProposal(); |
439 | 443 |
|
440 | 444 | testAllowTvmBlobProposal(); |
441 | | - |
| 445 | + ThrowingRunnable r0 = () -> ProposalUtil.validator(dynamicPropertiesStore, forkUtils, |
| 446 | + ProposalType.ALLOW_MARKET_TRANSACTION.getCode(), 0); |
| 447 | + ThrowingRunnable r1 = () -> ProposalUtil.validator(dynamicPropertiesStore, forkUtils, |
| 448 | + ProposalType.ALLOW_MARKET_TRANSACTION.getCode(), 1); |
| 449 | + ContractValidateException thrown = assertThrows(ContractValidateException.class, r1); |
| 450 | + assertEquals("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]", thrown.getMessage()); |
| 451 | + |
| 452 | + forkUtils.getManager().getDynamicPropertiesStore().statsByVersion( |
| 453 | + ForkBlockVersionEnum.VERSION_4_1.getValue(), stats); |
| 454 | + try { |
| 455 | + r1.run(); |
| 456 | + } catch (Throwable e) { |
| 457 | + Assert.fail(e.getMessage()); |
| 458 | + } |
| 459 | + thrown = assertThrows(ContractValidateException.class, r0); |
| 460 | + assertEquals("This value[ALLOW_MARKET_TRANSACTION] is only allowed to be 1", |
| 461 | + thrown.getMessage()); |
442 | 462 | testAllowTvmSelfdestructRestrictionProposal(); |
443 | 463 |
|
| 464 | + thrown = assertThrows(ContractValidateException.class, r1); |
| 465 | + assertEquals("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]", thrown.getMessage()); |
| 466 | + |
444 | 467 | forkUtils.getManager().getDynamicPropertiesStore() |
445 | 468 | .statsByVersion(ForkBlockVersionEnum.ENERGY_LIMIT.getValue(), stats); |
446 | 469 | forkUtils.reset(); |
@@ -710,7 +733,6 @@ private void testAllowTvmSelfdestructRestrictionProposal() { |
710 | 733 | "[ALLOW_TVM_SELFDESTRUCT_RESTRICTION] has been valid, no need to propose again", |
711 | 734 | e.getMessage()); |
712 | 735 | } |
713 | | - |
714 | 736 | } |
715 | 737 |
|
716 | 738 | @Test |
|
0 commit comments