use of co.rsk.peg.ReleaseTransactionSet in project rskj by rsksmart.
the class UpdateCollectionsTest method updateCollections_confirmTxs.
private void updateCollections_confirmTxs(ExecutionStats stats, int numCases) throws IOException {
final int minTxsWaitingForSigs = 0;
final int maxTxsWaitingForSigs = 10;
final int minReleaseTxs = 1;
final int maxReleaseTxs = 100;
final int minBlockNumber = 10;
final int maxBlockNumber = 100;
final int minHeight = 50;
final int maxHeight = 150;
final int minCentOutput = 1;
final int maxCentOutput = 100;
final NetworkParameters parameters = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
BridgeStorageProviderInitializer storageInitializer = (BridgeStorageProvider provider, Repository repository, int executionIndex) -> {
Random rnd = new Random();
SortedMap<Keccak256, BtcTransaction> txsWaitingForSignatures;
ReleaseTransactionSet txSet;
try {
txsWaitingForSignatures = provider.getRskTxsWaitingForSignatures();
} catch (Exception e) {
throw new RuntimeException("Unable to gather txs waiting for signatures");
}
try {
txSet = provider.getReleaseTransactionSet();
} catch (Exception e) {
throw new RuntimeException("Unable to gather release tx set");
}
// Generate some txs waiting for signatures
Script genesisFederationScript = bridgeConstants.getGenesisFederation().getP2SHScript();
for (int i = 0; i < Helper.randomInRange(minTxsWaitingForSigs, maxTxsWaitingForSigs); i++) {
Keccak256 rskHash = new Keccak256(HashUtil.keccak256(BigInteger.valueOf(rnd.nextLong()).toByteArray()));
BtcTransaction btcTx = new BtcTransaction(networkParameters);
Sha256Hash inputHash = Sha256Hash.wrap(HashUtil.sha256(BigInteger.valueOf(rnd.nextLong()).toByteArray()));
btcTx.addInput(inputHash, 0, genesisFederationScript);
btcTx.addOutput(Helper.randomCoin(Coin.CENT, minCentOutput, maxCentOutput), new BtcECKey());
txsWaitingForSignatures.put(rskHash, btcTx);
}
// Generate some txs waiting for confirmations
for (int i = 0; i < Helper.randomInRange(minReleaseTxs, maxReleaseTxs); i++) {
BtcTransaction btcTx = new BtcTransaction(networkParameters);
Sha256Hash inputHash = Sha256Hash.wrap(HashUtil.sha256(BigInteger.valueOf(rnd.nextLong()).toByteArray()));
btcTx.addInput(inputHash, 0, genesisFederationScript);
btcTx.addOutput(Helper.randomCoin(Coin.CENT, minCentOutput, maxCentOutput), new BtcECKey());
long blockNumber = Helper.randomInRange(minBlockNumber, maxBlockNumber);
txSet.add(btcTx, blockNumber);
}
};
final byte[] updateCollectionsEncoded = Bridge.UPDATE_COLLECTIONS.encode();
ABIEncoder abiEncoder = (int executionIndex) -> updateCollectionsEncoded;
HeightProvider heightProvider = (int executionIndex) -> Helper.randomInRange(minHeight, maxHeight);
executeAndAverage("updateCollections-releaseTxs", numCases, abiEncoder, storageInitializer, Helper.getZeroValueRandomSenderTxBuilder(), heightProvider, stats);
}
Aggregations