use of org.aion.zero.impl.forks.ForkUtility in project aion by aionnetwork.
the class BeaconHashValidatorTest method validateTxForPendingStateWithoutBeaconHash.
@Test
public void validateTxForPendingStateWithoutBeaconHash() {
long unityForkNumber = 3;
ForkUtility forkUtility = new ForkUtility();
forkUtility.enableUnityFork(unityForkNumber);
IAionBlockchain blockchain = mock(IAionBlockchain.class);
Block bestBlock = mock(Block.class);
when(blockchain.getBestBlock()).thenReturn(bestBlock);
AionTransaction tx = AionTransaction.createWithoutKey(// nonce - any val
new byte[] { 1 }, new AionAddress(// sender - any val
ByteUtil.hexStringToBytes("0xa000000000000000000000000000000000000000000000000000000000000000")), new AionAddress(// destination - any val
ByteUtil.hexStringToBytes("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")), // value - any val
new byte[] { 1 }, // data - any val
new byte[] {}, // energyLimit - any val
1l, // energyPrice - any val
1l, // type - any val
(byte) 1, // beacon hash - absent
null);
BeaconHashValidator unit = new BeaconHashValidator(blockchain, forkUtility);
when(bestBlock.getNumber()).thenReturn(unityForkNumber - 2);
assertWithMessage("validation should pass for pending state if beacon hash absent").that(unit.validateTxForPendingState(tx)).isTrue();
when(bestBlock.getNumber()).thenReturn(unityForkNumber - 1);
assertWithMessage("validation should pass for pending state if beacon hash absent").that(unit.validateTxForPendingState(tx)).isTrue();
when(bestBlock.getNumber()).thenReturn(unityForkNumber);
assertWithMessage("validation should pass for pending state if beacon hash absent").that(unit.validateTxForPendingState(tx)).isTrue();
}
Aggregations