use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class BridgeSupportTest method removeLockWhitelistAddress_invalidAddress.
@Test
public void removeLockWhitelistAddress_invalidAddress() throws IOException {
Transaction mockedTx = mock(Transaction.class);
byte[] senderBytes = ECKey.fromPublicOnly(Hex.decode(// Public key hex of the authorized whitelist admin in regtest, taken from BridgeRegTestConstants
"04641fb250d7ca7a1cb4f530588e978013038ec4294d084d248869dd54d98873e45c61d00ceeaeeb9e35eab19fa5fbd8f07cb8a5f0ddba26b4d4b18349c09199ad")).getAddress();
RskAddress sender = new RskAddress(senderBytes);
when(mockedTx.getSender()).thenReturn(sender);
LockWhitelist mockedWhitelist = mock(LockWhitelist.class);
BridgeSupport bridgeSupport = getBridgeSupportWithMocksForWhitelistTests(mockedWhitelist);
Assert.assertEquals(-2, bridgeSupport.removeLockWhitelistAddress(mockedTx, "i-am-invalid").intValue());
verify(mockedWhitelist, never()).remove(any());
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class BridgeSupportTest method voteFederationChange_notAuthorized.
@Test
public void voteFederationChange_notAuthorized() throws IOException {
BridgeSupport bridgeSupport = getBridgeSupportWithMocksForFederationTests(false, null, null, null, null, null, null);
ABICallSpec spec = new ABICallSpec("create", new byte[][] {});
Transaction mockedTx = mock(Transaction.class);
when(mockedTx.getSender()).thenReturn(new RskAddress(ECKey.fromPrivate(BigInteger.valueOf(12L)).getAddress()));
Assert.assertEquals(BridgeSupport.FEDERATION_CHANGE_GENERIC_ERROR_CODE, bridgeSupport.voteFederationChange(mockedTx, spec));
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class RskForksBridgeTest method before.
@Before
public void before() throws IOException, ClassNotFoundException {
World world = new World();
blockChain = world.getBlockChain();
repository = blockChain.getRepository();
whitelistManipulationKey = ECKey.fromPrivate(Hex.decode("3890187a3071327cee08467ba1b44ed4c13adb2da0d5ffcc0563c371fa88259c"));
genesis = (Genesis) blockChain.getBestBlock();
keyHoldingRSKs = new ECKey();
co.rsk.core.Coin balance = new co.rsk.core.Coin(new BigInteger("10000000000000000000"));
repository.addBalance(new RskAddress(keyHoldingRSKs.getAddress()), balance);
genesis.setStateRoot(repository.getRoot());
genesis.flushRLP();
blockChain.getBlockStore().saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
Transaction whitelistAddressTx = buildWhitelistTx();
Transaction receiveHeadersTx = buildReceiveHeadersTx();
Transaction registerBtctransactionTx = buildRegisterBtcTransactionTx();
blockBase = buildBlock(genesis, whitelistAddressTx, receiveHeadersTx, registerBtctransactionTx);
Assert.assertEquals(ImportResult.IMPORTED_BEST, blockChain.tryToConnect(blockBase));
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class MinerUtilsTest method harmfulTransactionTest.
@Test
public void harmfulTransactionTest() {
Transaction tx = Tx.create(config, 0, 50000, 1, 0, 0, 0);
List<Transaction> txs = new LinkedList<>();
txs.add(tx);
Mockito.when(tx.getGasPrice()).thenReturn(null);
Map<RskAddress, BigInteger> accountNounces = new HashMap();
byte[] addressBytes = ByteUtil.leftPadBytes(BigInteger.valueOf(new Random(0).nextLong()).toByteArray(), 20);
accountNounces.put(new RskAddress(addressBytes), BigInteger.valueOf(0));
Repository repository = Mockito.mock(Repository.class);
Coin minGasPrice = Coin.valueOf(2L);
LinkedList<Transaction> txsToRemove = new LinkedList<>();
List<Transaction> res = new MinerUtils().filterTransactions(txsToRemove, txs, accountNounces, repository, minGasPrice);
Assert.assertEquals(0, res.size());
Assert.assertEquals(1, txsToRemove.size());
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class MinerUtilsTest method invalidGasPriceTransactionTest.
@Test
public void invalidGasPriceTransactionTest() {
Transaction tx = Tx.create(config, 0, 50000, 1, 0, 0, 0);
List<Transaction> txs = new LinkedList<>();
txs.add(tx);
Map<RskAddress, BigInteger> accountNounces = new HashMap();
byte[] addressBytes = ByteUtil.leftPadBytes(BigInteger.valueOf(new Random(0).nextLong()).toByteArray(), 20);
accountNounces.put(new RskAddress(addressBytes), BigInteger.valueOf(0));
Repository repository = Mockito.mock(Repository.class);
Coin minGasPrice = Coin.valueOf(2L);
LinkedList<Transaction> txsToRemove = new LinkedList<>();
List<Transaction> res = new MinerUtils().filterTransactions(txsToRemove, txs, accountNounces, repository, minGasPrice);
Assert.assertEquals(0, res.size());
Assert.assertEquals(1, txsToRemove.size());
}
Aggregations