use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class MinerUtilsTest method invalidNonceTransactionTest.
@Test
public void invalidNonceTransactionTest() {
Transaction tx = Tx.create(config, 0, 50000, 2, 0, 0, 0);
List<Transaction> txs = new LinkedList<>();
txs.add(tx);
Map<RskAddress, BigInteger> accountNounces = new HashMap();
accountNounces.put(tx.getSender(), BigInteger.valueOf(0));
Repository repository = Mockito.mock(Repository.class);
Coin minGasPrice = Coin.valueOf(1L);
List<Transaction> txsToRemove = new LinkedList<>();
List<Transaction> res = new MinerUtils().filterTransactions(txsToRemove, txs, accountNounces, repository, minGasPrice);
Assert.assertEquals(0, res.size());
Assert.assertEquals(0, txsToRemove.size());
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class TestProgramInvokeFactory method generalInvoke.
private ProgramInvoke generalInvoke(Transaction tx, int txindex, Repository repository, BlockStore blockStore) {
/**
* ADDRESS op **
*/
// YP: Get address of currently executing account.
RskAddress addr = tx.isContractCreation() ? tx.getContractAddress() : tx.getReceiveAddress();
/**
* ORIGIN op **
*/
// YP: This is the sender of original transaction; it is never a contract.
RskAddress origin = tx.getSender();
/**
* CALLER op **
*/
// YP: This is the address of the account that is directly responsible for this execution.
RskAddress caller = tx.getSender();
/**
* BALANCE op **
*/
Coin balance = repository.getBalance(addr);
/**
* GASPRICE op **
*/
Coin gasPrice = tx.getGasPrice();
/**
* GAS op **
*/
byte[] gas = tx.getGasLimit();
/**
* CALLVALUE op **
*/
Coin callValue = tx.getValue() == null ? Coin.ZERO : tx.getValue();
/**
* CALLDATALOAD op **
*/
/**
* CALLDATACOPY op **
*/
/**
* CALLDATASIZE op **
*/
byte[] data = tx.isContractCreation() ? ByteUtil.EMPTY_BYTE_ARRAY : (tx.getData() == null ? ByteUtil.EMPTY_BYTE_ARRAY : tx.getData());
// byte[] data = tx.getData() == null ? ByteUtil.EMPTY_BYTE_ARRAY : tx.getData() ;
/**
* PREVHASH op **
*/
byte[] lastHash = env.getPreviousHash();
/**
* COINBASE op **
*/
byte[] coinbase = env.getCurrentCoinbase();
/**
* TIMESTAMP op **
*/
long timestamp = ByteUtil.byteArrayToLong(env.getCurrentTimestamp());
/**
* NUMBER op **
*/
long number = ByteUtil.byteArrayToLong(env.getCurrentNumber());
/**
* DIFFICULTY op **
*/
byte[] difficulty = env.getCurrentDifficulty();
/**
* GASLIMIT op **
*/
byte[] gaslimit = env.getCurrentGasLimit();
return new ProgramInvokeImpl(addr.getBytes(), origin.getBytes(), caller.getBytes(), balance.getBytes(), gasPrice.getBytes(), gas, callValue.getBytes(), data, lastHash, coinbase, timestamp, number, txindex, difficulty, gaslimit, repository, blockStore);
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class TestRunner method loadRepository.
public Repository loadRepository(Repository track, Map<RskAddress, AccountState> pre) {
/* 1. Store pre-exist accounts - Pre */
for (RskAddress addr : pre.keySet()) {
AccountState accountState = pre.get(addr);
track.addBalance(addr, accountState.getBalance());
((RepositoryTrack) track).setNonce(addr, new BigInteger(1, accountState.getNonce()));
track.saveCode(addr, accountState.getCode());
for (DataWord storageKey : accountState.getStorage().keySet()) {
track.addStorageRow(addr, storageKey, accountState.getStorage().get(storageKey));
}
}
return track;
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class AddressesTopicsFilterTest method matchAddress.
@Test
public void matchAddress() {
Account account = new AccountBuilder().name("account").build();
RskAddress address = account.getAddress();
AddressesTopicsFilter filter = new AddressesTopicsFilter(new RskAddress[] { address }, null);
Assert.assertTrue(filter.matchesContractAddress(address));
Assert.assertFalse(filter.matchesContractAddress(RskAddress.nullAddress()));
}
use of co.rsk.core.RskAddress in project rskj by rsksmart.
the class AddressesTopicsFilterTest method matchAllBloomWithFilterWithAccount.
@Test
public void matchAllBloomWithFilterWithAccount() {
Account account = new AccountBuilder().name("account").build();
RskAddress address = account.getAddress();
AddressesTopicsFilter filter = new AddressesTopicsFilter(new RskAddress[] { address }, null);
Assert.assertTrue(filter.matchBloom(getAllBloom()));
}
Aggregations