From cb9d7dc6e2f086ebca3344180d99399f65e55d79 Mon Sep 17 00:00:00 2001 From: Marcos Date: Sat, 10 Aug 2024 16:05:58 -0300 Subject: [PATCH] Rework LockingCap integration tests --- .../java/co/rsk/peg/BridgeSupportTest.java | 2 +- .../rsk/peg/lockingcap/LockingCapCaller.java | 4 +- .../co/rsk/peg/lockingcap/LockingCapIT.java | 252 ++++++++---------- .../lockingcap/LockingCapSupportImplTest.java | 24 +- 4 files changed, 126 insertions(+), 156 deletions(-) diff --git a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java index a29781732d1..3fe2e995911 100644 --- a/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/BridgeSupportTest.java @@ -567,7 +567,7 @@ void getLockingCap_whenLockingCapIsEmpty_shouldReturnNull() { void increaseLockingCap() throws VMException { // Arrange Coin newLockingCap = constants.getInitialValue().add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); when(lockingCapSupport.increaseLockingCap(tx, newLockingCap)).thenReturn(true); when(lockingCapSupport.getLockingCap()).thenReturn(Optional.of(newLockingCap)); diff --git a/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapCaller.java b/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapCaller.java index c091629310f..27b89ce362d 100644 --- a/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapCaller.java +++ b/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapCaller.java @@ -3,7 +3,9 @@ import co.rsk.core.RskAddress; public enum LockingCapCaller { - AUTHORIZED("a02db0ed94a5894bc6f9079bb9a2d93ada1917f3"), + FIRST_AUTHORIZED("a02db0ed94a5894bc6f9079bb9a2d93ada1917f3"), + SECOND_AUTHORIZED("180a7edda4e640ea5a3e495e17a1efad260c39e9"), + THIRD_AUTHORIZED("8418edc8fea47183116b4c8cd6a12e51a7e169c1"), UNAUTHORIZED("e2a5070b4e2cb77fe22dff05d9dcdc4d3eaa6ead"); private final String rskAddress; diff --git a/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapIT.java b/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapIT.java index 49ec7f7842f..546d6cc6b0e 100644 --- a/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapIT.java +++ b/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapIT.java @@ -1,9 +1,6 @@ package co.rsk.peg.lockingcap; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import co.rsk.bitcoinj.core.Coin; import co.rsk.net.utils.TransactionUtils; @@ -14,27 +11,17 @@ import java.util.Optional; import org.ethereum.config.blockchain.upgrades.ActivationConfig; import org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest; -import org.ethereum.core.BlockTxSignatureCache; -import org.ethereum.core.ReceivedTxSignatureCache; -import org.ethereum.core.SignatureCache; -import org.ethereum.core.Transaction; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; +import org.ethereum.core.*; +import org.junit.jupiter.api.*; import org.junit.jupiter.api.TestInstance.Lifecycle; -import org.junit.jupiter.api.TestMethodOrder; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestInstance(Lifecycle.PER_CLASS) class LockingCapIT { - private final LockingCapConstants constants = LockingCapMainNetConstants.getInstance(); private LockingCapSupport lockingCapSupport; private LockingCapStorageProvider lockingCapStorageProvider; private SignatureCache signatureCache; - private ActivationConfig.ForBlock activations; private StorageAccessor bridgeStorageAccessor; private Coin currentLockingCap; // it is used to guarantee the value from getLockingCap() contains the value expected @@ -43,6 +30,14 @@ void setUp() { bridgeStorageAccessor = new InMemoryStorage(); lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); signatureCache = new BlockTxSignatureCache(new ReceivedTxSignatureCache()); + + ActivationConfig.ForBlock activations = ActivationConfigsForTest.all().forBlock(0); + lockingCapSupport = new LockingCapSupportImpl( + lockingCapStorageProvider, + activations, + constants, + signatureCache + ); } @Test @@ -50,55 +45,49 @@ void setUp() { void increaseLockingCap_prePapyrus200_whenLockingCapIsNotSet_shouldNotSavedNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange // Previously to the genesis of the Locking Cap - activations = ActivationConfigsForTest.wasabi100().forBlock(0); - lockingCapSupport = new LockingCapSupportImpl(lockingCapStorageProvider, activations, constants, signatureCache); + ActivationConfig.ForBlock wasabiActivations = ActivationConfigsForTest.wasabi100().forBlock(0); + LockingCapSupport wasabiLockingCapSupport = new LockingCapSupportImpl( + lockingCapStorageProvider, + wasabiActivations, + constants, + signatureCache + ); // Setting up new Locking Cap value Coin newLockingCap = constants.getInitialValue(); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller( + signatureCache, + LockingCapCaller.FIRST_AUTHORIZED.getRskAddress() + ); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); + boolean isIncreased = wasabiLockingCapSupport.increaseLockingCap(tx, newLockingCap); // Assert - assertFalse(isIncrease); + assertFalse(isIncreased); } @Test @Order(0) void getInitialValue_whenFirstTimeGettingLockingCap_shouldReturnInitialValue() { - // Arrange - activations = ActivationConfigsForTest.all().forBlock(0); - lockingCapSupport = new LockingCapSupportImpl(lockingCapStorageProvider, activations, constants, signatureCache); // The first time the Locking Cap is requested, it should return the initial value - Coin initialValue = constants.getInitialValue(); - currentLockingCap = initialValue; + Coin expectedLockingCap = constants.getInitialValue(); // Actual / Assert - assertLockingCapValue(initialValue); + assertLockingCapValue(expectedLockingCap); } @Test @Order(1) void increaseLockingCap_whenNewValueIsGreaterThanCurrentLockingCap_shouldSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value - Coin newLockingCap = currentLockingCap.add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Coin newLockingCap = currentLockingCap.add(Coin.COIN); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); - if (isIncrease){ - lockingCapSupport.save(); - currentLockingCap = newLockingCap; - } + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap); // Assert - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertTrue(isIncreased); assertLockingCapValue(newLockingCap); } @@ -106,48 +95,27 @@ void increaseLockingCap_whenNewValueIsGreaterThanCurrentLockingCap_shouldSaveNew @Order(2) void increaseLockingCap_whenPreviousValueExistsInStorageAndNewLockingCapIsLessThanPreviousValue_shouldNotSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value - Coin newLockingCap = currentLockingCap.subtract(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Coin newLockingCap = currentLockingCap.subtract(Coin.COIN); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap); // Assert - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertFalse(isIncreased); assertLockingCapValue(currentLockingCap); - assertFalse(isIncrease); } @Test @Order(3) void increaseLockingCap_whenPreviousValueExistsInStorageAndNewLockingCapIsGreaterThanPreviousValue_shouldSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value - Coin newLockingCap = currentLockingCap.add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Coin newLockingCap = currentLockingCap.add(Coin.COIN); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); - if (isIncrease){ - lockingCapSupport.save(); - currentLockingCap = newLockingCap; - } + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap); // Assert - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertTrue(isIncreased); assertLockingCapValue(newLockingCap); } @@ -155,147 +123,147 @@ void increaseLockingCap_whenPreviousValueExistsInStorageAndNewLockingCapIsGreate @Order(4) void increaseLockingCap_whenAnUnauthorizedCallerRequestToIncreaseLockingCapValue_shouldNotSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value - Coin newLockingCap = currentLockingCap.add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.UNAUTHORIZED.getRskAddress()); + Coin newLockingCap = currentLockingCap.add(Coin.COIN); + Transaction tx = TransactionUtils.getTransactionFromCaller( + signatureCache, + LockingCapCaller.UNAUTHORIZED.getRskAddress() + ); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); + boolean isIncreased = lockingCapSupport.increaseLockingCap(tx, newLockingCap); // Assert - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertFalse(isIncreased); assertLockingCapValue(currentLockingCap); - assertFalse(isIncrease); } @Test @Order(5) - void increaseLockingCap_whenNewLockingCapIsGreaterThanMaxLockingCap_shouldNotSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { + void increaseLockingCap_whenSecondAuthorizedCallerRequestToIncreaseLockingCapValue_shouldSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); + Coin newLockingCap = currentLockingCap.add(Coin.COIN); - // Setting up new Locking Cap value + // Act + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap, LockingCapCaller.SECOND_AUTHORIZED); + + // Assert + assertTrue(isIncreased); + assertLockingCapValue(newLockingCap); + } + + @Test + @Order(6) + void increaseLockingCap_whenThirdAuthorizedCallerRequestToIncreaseLockingCapValue_shouldSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { + // Arrange + Coin newLockingCap = currentLockingCap.add(Coin.COIN); + + // Act + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap, LockingCapCaller.THIRD_AUTHORIZED); + + // Assert + assertTrue(isIncreased); + assertLockingCapValue(newLockingCap); + } + + @Test + @Order(7) + void increaseLockingCap_whenNewLockingCapIsGreaterThanMaxLockingCap_shouldNotSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { + // Arrange Coin maxLockingCapVoteValueAllowed = currentLockingCap.multiply(constants.getIncrementsMultiplier()); Coin newLockingCap = maxLockingCapVoteValueAllowed.add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap); // Assert - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertFalse(isIncreased); assertLockingCapValue(currentLockingCap); - assertFalse(isIncrease); } @Test - @Order(6) + @Order(8) void increaseLockingCap_whenNewLockingCapIsEqualToMaxLockingCap_shouldSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value Coin newLockingCap = currentLockingCap.multiply(constants.getIncrementsMultiplier()); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); - if (isIncrease){ - lockingCapSupport.save(); - currentLockingCap = newLockingCap; - } + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap); // Assert - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertTrue(isIncreased); assertLockingCapValue(newLockingCap); } @Test - @Order(7) + @Order(9) void increaseLockingCap_whenNewLockingCapIsZero_shouldThrowLockingCapIllegalArgumentException() { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value Coin newLockingCap = Coin.ZERO; - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); // Actual / Assert - assertThrows(LockingCapIllegalArgumentException.class, () -> lockingCapSupport.increaseLockingCap(tx, newLockingCap)); - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertThrows( + LockingCapIllegalArgumentException.class, + () -> voteToIncreaseLockingCap(newLockingCap) + ); assertLockingCapValue(currentLockingCap); } @Test - @Order(8) + @Order(10) void increaseLockingCap_whenNewLockingCapIsNegative_shouldThrowLockingCapIllegalArgumentException() { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value Coin newLockingCap = Coin.NEGATIVE_SATOSHI; - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); // Actual / Assert - assertThrows(LockingCapIllegalArgumentException.class, () -> lockingCapSupport.increaseLockingCap(tx, newLockingCap)); - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertThrows( + LockingCapIllegalArgumentException.class, + () -> voteToIncreaseLockingCap(newLockingCap) + ); assertLockingCapValue(currentLockingCap); } @Test - @Order(9) + @Order(11) void increaseLockingCap_whenNewValueIsEqualToCurrentValue_shouldSaveNewLockingCapValue() throws LockingCapIllegalArgumentException { // Arrange - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); - // Ensure the value is the same as the one saved in the storage - assertLockingCapValue(currentLockingCap); - - // Setting up new Locking Cap value Coin newLockingCap = currentLockingCap; - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); // Act - boolean isIncrease = lockingCapSupport.increaseLockingCap(tx, newLockingCap); - if (isIncrease){ - lockingCapSupport.save(); - currentLockingCap = newLockingCap; - } + boolean isIncreased = voteToIncreaseLockingCap(newLockingCap); // Assert - // Recreate LockingCapStorageProvider to clear cached value and make sure it was saved in the storage - lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + assertTrue(isIncreased); assertLockingCapValue(newLockingCap); } + private boolean voteToIncreaseLockingCap(Coin valueToVote) throws LockingCapIllegalArgumentException { + return voteToIncreaseLockingCap(valueToVote, LockingCapCaller.FIRST_AUTHORIZED); + } + + private boolean voteToIncreaseLockingCap(Coin valueToVote, LockingCapCaller caller) throws LockingCapIllegalArgumentException { + Transaction tx = TransactionUtils.getTransactionFromCaller( + signatureCache, + caller.getRskAddress() + ); + + boolean result = lockingCapSupport.increaseLockingCap(tx, valueToVote); + lockingCapSupport.save(); + + return result; + } + private void assertLockingCapValue(Coin expectedLockingCap) { + // Recreate LockingCapStorageProvider to clear cached value and make sure it is fetched from the storage + lockingCapStorageProvider = new LockingCapStorageProviderImpl(bridgeStorageAccessor); + // Act Optional actualLockingCap = lockingCapSupport.getLockingCap(); // Assert assertTrue(actualLockingCap.isPresent()); assertEquals(expectedLockingCap, actualLockingCap.get()); + + // Save the current Locking Cap value to be used in the next test + currentLockingCap = actualLockingCap.get(); } } diff --git a/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapSupportImplTest.java b/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapSupportImplTest.java index faa02955d58..e9a180b9e26 100644 --- a/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapSupportImplTest.java +++ b/rskj-core/src/test/java/co/rsk/peg/lockingcap/LockingCapSupportImplTest.java @@ -84,7 +84,7 @@ void increaseLockingCap_whenNewValueIsGreaterThanCurrentLockingCap_shouldReturnT throws LockingCapIllegalArgumentException { // Arrange Coin newLockingCap = constants.getInitialValue().add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -99,7 +99,7 @@ void increaseLockingCap_whenNewValueIsLessThanInitialValue_shouldReturnFalse() throws LockingCapIllegalArgumentException { // Arrange Coin newLockingCap = constants.getInitialValue().subtract(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -121,7 +121,7 @@ void increaseLockingCap_whenPreviousValueExistsInStorageAndNewLockingCapIsGreate lockingCapSupport = new LockingCapSupportImpl(lockingCapStorageProvider, activations, constants, signatureCache); Coin newLockingCap = previousLockingCap.add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -143,7 +143,7 @@ void increaseLockingCap_whenPreviousValueExistsInStorageAndNewLockingCapIsLessTh lockingCapSupport = new LockingCapSupportImpl(lockingCapStorageProvider, activations, constants, signatureCache); Coin newLockingCap = expectedLockingCap.subtract(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -181,7 +181,7 @@ void increaseLockingCap_whenNewLockingCapIsGreaterThanMaxLockingCap_shouldReturn Coin maxLockingCapVoteValueAllowed = expectedLockingCap.multiply(constants.getIncrementsMultiplier()); Coin newLockingCap = maxLockingCapVoteValueAllowed.add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -204,7 +204,7 @@ void increaseLockingCap_whenNewLockingCapIsEqualToMaxLockingCap_shouldReturnTrue // The new locking cap is the maximum value that can be set Coin newLockingCap = previousLockingCap.multiply(constants.getIncrementsMultiplier()); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -219,7 +219,7 @@ void increaseLockingCap_whenNewValueIsEqualToCurrentValue_shouldReturnTrue() throws LockingCapIllegalArgumentException { // Arrange Coin newLockingCap = constants.getInitialValue(); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -233,7 +233,7 @@ void increaseLockingCap_whenNewValueIsEqualToCurrentValue_shouldReturnTrue() void increaseLockingCap_whenNewLockingCapIsZero_shouldReturnFalse() { // Arrange Coin newLockingCap = Coin.ZERO; - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act / Assert assertThrows(LockingCapIllegalArgumentException.class, () -> lockingCapSupport.increaseLockingCap(tx, newLockingCap)); @@ -244,7 +244,7 @@ void increaseLockingCap_whenNewLockingCapIsZero_shouldReturnFalse() { void increaseLockingCap_whenNewLockingCapIsNegative_shouldReturnFalse() { // Arrange Coin newLockingCap = Coin.NEGATIVE_SATOSHI; - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act / Assert assertThrows(LockingCapIllegalArgumentException.class, () -> lockingCapSupport.increaseLockingCap(tx, newLockingCap)); @@ -258,7 +258,7 @@ void increaseLockingCap_prePapyrus200_whenLockingCapIsNotSet_shouldReturnFalse() activations = ActivationConfigsForTest.wasabi100().forBlock(0); lockingCapSupport = new LockingCapSupportImpl(lockingCapStorageProvider, activations, constants, signatureCache); Coin newLockingCap = constants.getInitialValue().add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); // Act boolean actualResult = lockingCapSupport.increaseLockingCap(tx, newLockingCap); @@ -273,7 +273,7 @@ void save_whenIsIncreasedLockingCapValue_shouldSaveLockingCap() throws LockingCapIllegalArgumentException { // Arrange Coin newLockingCap = constants.getInitialValue().add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); lockingCapSupport.increaseLockingCap(tx, newLockingCap); // Act @@ -293,7 +293,7 @@ void save_prePapyrus200_whenIsAttemptedIncreaseLockingCapValue_shouldNotSaveLock activations = ActivationConfigsForTest.wasabi100().forBlock(0); lockingCapSupport = new LockingCapSupportImpl(lockingCapStorageProvider, activations, constants, signatureCache); Coin newLockingCap = constants.getInitialValue().add(Coin.SATOSHI); - Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.AUTHORIZED.getRskAddress()); + Transaction tx = TransactionUtils.getTransactionFromCaller(signatureCache, LockingCapCaller.FIRST_AUTHORIZED.getRskAddress()); lockingCapSupport.increaseLockingCap(tx, newLockingCap); // Act