Search in sources :

Example 36 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method registerBtcTransaction_accepts_lock_tx_with_witness_after_rskip_143_activation.

@Test
public void registerBtcTransaction_accepts_lock_tx_with_witness_after_rskip_143_activation() throws BlockStoreException, IOException, BridgeIllegalArgumentException {
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP143)).thenReturn(true);
    Federation federation1 = getFederation(bridgeConstants);
    Repository repository = createRepository();
    BtcTransaction tx1 = new BtcTransaction(btcParams);
    BtcECKey srcKey1 = new BtcECKey();
    ECKey key = ECKey.fromPublicOnly(srcKey1.getPubKey());
    Address btcAddress = srcKey1.toAddress(btcParams);
    RskAddress rskAddress = new RskAddress(key.getAddress());
    Coin amountToLock = Coin.COIN.multiply(10);
    tx1.addOutput(amountToLock, federation1.getAddress());
    tx1.addInput(PegTestUtils.createHash(1), 0, new Script(new byte[] {}));
    TransactionWitness txWit = new TransactionWitness(1);
    txWit.setPush(0, new byte[] {});
    tx1.setWitness(0, txWit);
    byte[] bits = new byte[1];
    bits[0] = 0x3f;
    List<Sha256Hash> hashes = new ArrayList<>();
    hashes.add(tx1.getHash());
    PartialMerkleTree pmtWithoutWitness = new PartialMerkleTree(btcParams, bits, hashes, 1);
    List<Sha256Hash> hashlist = new ArrayList<>();
    Sha256Hash blockMerkleRoot = pmtWithoutWitness.getTxnHashAndMerkleRoot(hashlist);
    co.rsk.bitcoinj.core.BtcBlock registerHeader = new co.rsk.bitcoinj.core.BtcBlock(btcParams, 1, PegTestUtils.createHash(1), blockMerkleRoot, 1, 1, 1, new ArrayList<>());
    List<Sha256Hash> hashes2 = new ArrayList<>();
    hashes2.add(tx1.getHash(true));
    PartialMerkleTree pmtWithWitness = new PartialMerkleTree(btcParams, bits, hashes2, 1);
    List<Sha256Hash> hashlist2 = new ArrayList<>();
    Sha256Hash witnessMerkleRoot = pmtWithWitness.getTxnHashAndMerkleRoot(hashlist2);
    int height = 50;
    StoredBlock block = new StoredBlock(registerHeader, new BigInteger("0"), height);
    BtcBlockStoreWithCache btcBlockStore = mock(BtcBlockStoreWithCache.class);
    co.rsk.bitcoinj.core.BtcBlock headBlock = new co.rsk.bitcoinj.core.BtcBlock(btcParams, 1, PegTestUtils.createHash(2), Sha256Hash.of(new byte[] { 1 }), 1, 1, 1, new ArrayList<>());
    StoredBlock chainHead = new StoredBlock(headBlock, new BigInteger("0"), 132);
    when(btcBlockStore.getChainHead()).thenReturn(chainHead);
    when(btcBlockStore.getStoredBlockAtMainChainHeight(block.getHeight())).thenReturn(block);
    BtcBlockStoreWithCache.Factory mockFactory = mock(BtcBlockStoreWithCache.Factory.class);
    when(mockFactory.newInstance(any(), any(), any(), any())).thenReturn(btcBlockStore);
    BridgeStorageProvider provider = new BridgeStorageProvider(repository, contractAddress, bridgeConstants, activations);
    provider.setNewFederation(federation1);
    // Whitelist the addresses
    LockWhitelist whitelist = provider.getLockWhitelist();
    whitelist.put(btcAddress, new OneOffWhiteListEntry(btcAddress, Coin.COIN.multiply(10)));
    BridgeSupport bridgeSupport = getBridgeSupport(bridgeConstants, provider, repository, getBtcLockSenderProvider(TxSenderAddressType.P2SHP2WPKH, btcAddress, rskAddress), new PeginInstructionsProvider(), mock(Block.class), mockFactory, activations);
    CoinbaseInformation coinbaseInformation = new CoinbaseInformation(witnessMerkleRoot);
    provider.setCoinbaseInformation(registerHeader.getHash(), coinbaseInformation);
    bridgeSupport.registerBtcTransaction(mock(Transaction.class), tx1.bitcoinSerialize(), height, pmtWithWitness.bitcoinSerialize());
    co.rsk.core.Coin totalAmountExpectedToHaveBeenLocked = co.rsk.core.Coin.fromBitcoin(amountToLock);
    Assert.assertEquals(totalAmountExpectedToHaveBeenLocked, repository.getBalance(rskAddress));
    Assert.assertEquals(1, provider.getNewFederationBtcUTXOs().size());
    Assert.assertEquals(amountToLock, provider.getNewFederationBtcUTXOs().get(0).getValue());
    Assert.assertEquals(0, provider.getReleaseRequestQueue().getEntries().size());
    Assert.assertEquals(0, provider.getReleaseTransactionSet().getEntries().size());
    Assert.assertTrue(provider.getRskTxsWaitingForSignatures().isEmpty());
    Assert.assertTrue(provider.getHeightIfBtcTxhashIsAlreadyProcessed(tx1.getHash(false)).isPresent());
}
Also used : RskAddress(co.rsk.core.RskAddress) ECKey(org.ethereum.crypto.ECKey) LockWhitelist(co.rsk.peg.whitelist.LockWhitelist) PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation) PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation) RskAddress(co.rsk.core.RskAddress) Script(co.rsk.bitcoinj.script.Script) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) CoinbaseInformation(co.rsk.peg.bitcoin.CoinbaseInformation) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) BigInteger(java.math.BigInteger) Block(org.ethereum.core.Block) OneOffWhiteListEntry(co.rsk.peg.whitelist.OneOffWhiteListEntry) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Example 37 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method eventLoggerLogLockBtc_before_rskip_146_activation.

@Test
public void eventLoggerLogLockBtc_before_rskip_146_activation() throws Exception {
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP146)).thenReturn(false);
    BridgeEventLogger mockedEventLogger = mock(BridgeEventLogger.class);
    BridgeStorageProvider mockBridgeStorageProvider = mock(BridgeStorageProvider.class);
    when(mockBridgeStorageProvider.getHeightIfBtcTxhashIsAlreadyProcessed(any(Sha256Hash.class))).thenReturn(Optional.empty());
    LockWhitelist lockWhitelist = mock(LockWhitelist.class);
    when(lockWhitelist.isWhitelistedFor(any(Address.class), any(Coin.class), any(int.class))).thenReturn(true);
    when(mockBridgeStorageProvider.getLockWhitelist()).thenReturn(lockWhitelist);
    when(mockBridgeStorageProvider.getNewFederation()).thenReturn(bridgeConstants.getGenesisFederation());
    Block executionBlock = mock(Block.class);
    BtcBlockStoreWithCache.Factory btcBlockStoreFactory = mock(BtcBlockStoreWithCache.Factory.class);
    BtcBlockStoreWithCache btcBlockStore = mock(BtcBlockStoreWithCache.class);
    when(btcBlockStoreFactory.newInstance(any(Repository.class), any(), any(), any())).thenReturn(btcBlockStore);
    // Create transaction
    Coin lockValue = Coin.COIN;
    BtcTransaction tx = new BtcTransaction(bridgeConstants.getBtcParams());
    tx.addOutput(lockValue, mockBridgeStorageProvider.getNewFederation().getAddress());
    BtcECKey srcKey = new BtcECKey();
    tx.addInput(PegTestUtils.createHash(1), 0, ScriptBuilder.createInputScript(null, srcKey));
    // Create header and PMT
    byte[] bits = new byte[1];
    bits[0] = 0x3f;
    List<Sha256Hash> hashes = new ArrayList<>();
    hashes.add(tx.getHash());
    PartialMerkleTree pmt = new PartialMerkleTree(bridgeConstants.getBtcParams(), bits, hashes, 1);
    Sha256Hash merkleRoot = pmt.getTxnHashAndMerkleRoot(new ArrayList<>());
    co.rsk.bitcoinj.core.BtcBlock btcBlock = new co.rsk.bitcoinj.core.BtcBlock(bridgeConstants.getBtcParams(), 1, PegTestUtils.createHash(), merkleRoot, 1, 1, 1, new ArrayList<>());
    int height = 1;
    mockChainOfStoredBlocks(btcBlockStore, btcBlock, height + bridgeConstants.getBtc2RskMinimumAcceptableConfirmations(), height);
    BridgeSupport bridgeSupport = bridgeSupportBuilder.withBridgeConstants(bridgeConstants).withProvider(mockBridgeStorageProvider).withEventLogger(mockedEventLogger).withBtcLockSenderProvider(new BtcLockSenderProvider()).withPeginInstructionsProvider(new PeginInstructionsProvider()).withExecutionBlock(executionBlock).withBtcBlockStoreFactory(btcBlockStoreFactory).withActivations(activations).build();
    bridgeSupport.registerBtcTransaction(mock(Transaction.class), tx.bitcoinSerialize(), height, pmt.bitcoinSerialize());
    verify(mockedEventLogger, never()).logLockBtc(any(RskAddress.class), any(BtcTransaction.class), any(Address.class), any(Coin.class));
}
Also used : RskAddress(co.rsk.core.RskAddress) BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) LockWhitelist(co.rsk.peg.whitelist.LockWhitelist) RskAddress(co.rsk.core.RskAddress) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) Block(org.ethereum.core.Block) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Example 38 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method registerBtcTransaction_rejects_tx_with_witness_and_unqual_witness_root_after_rskip_143_activation.

@Test
public void registerBtcTransaction_rejects_tx_with_witness_and_unqual_witness_root_after_rskip_143_activation() throws BlockStoreException, IOException, BridgeIllegalArgumentException {
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP143)).thenReturn(true);
    Repository repository = createRepository();
    BtcTransaction tx1 = new BtcTransaction(btcParams);
    BtcECKey srcKey1 = new BtcECKey();
    ECKey key = ECKey.fromPublicOnly(srcKey1.getPubKey());
    Address btcAddress = srcKey1.toAddress(btcParams);
    RskAddress rskAddress = new RskAddress(key.getAddress());
    Coin amountToLock = Coin.COIN.multiply(10);
    tx1.addOutput(amountToLock, Address.fromBase58(btcParams, "mvbnrCX3bg1cDRUu8pkecrvP6vQkSLDSou"));
    tx1.addInput(PegTestUtils.createHash(1), 0, new Script(new byte[] {}));
    TransactionWitness txWit = new TransactionWitness(1);
    txWit.setPush(0, new byte[] {});
    tx1.setWitness(0, txWit);
    byte[] bits = new byte[1];
    bits[0] = 0x3f;
    List<Sha256Hash> hashes = new ArrayList<>();
    hashes.add(tx1.getHash());
    PartialMerkleTree pmtWithoutWitness = new PartialMerkleTree(btcParams, bits, hashes, 1);
    List<Sha256Hash> hashlist = new ArrayList<>();
    Sha256Hash blockMerkleRoot = pmtWithoutWitness.getTxnHashAndMerkleRoot(hashlist);
    co.rsk.bitcoinj.core.BtcBlock registerHeader = new co.rsk.bitcoinj.core.BtcBlock(btcParams, 1, PegTestUtils.createHash(1), blockMerkleRoot, 1, 1, 1, new ArrayList<>());
    List<Sha256Hash> hashes2 = new ArrayList<>();
    hashes2.add(tx1.getHash(true));
    PartialMerkleTree pmtWithWitness = new PartialMerkleTree(btcParams, bits, hashes2, 1);
    int height = 50;
    StoredBlock block = new StoredBlock(registerHeader, new BigInteger("0"), height);
    BtcBlockStoreWithCache btcBlockStore = mock(BtcBlockStoreWithCache.class);
    co.rsk.bitcoinj.core.BtcBlock headBlock = new co.rsk.bitcoinj.core.BtcBlock(btcParams, 1, PegTestUtils.createHash(2), Sha256Hash.of(new byte[] { 1 }), 1, 1, 1, new ArrayList<>());
    StoredBlock chainHead = new StoredBlock(headBlock, new BigInteger("0"), 132);
    when(btcBlockStore.getChainHead()).thenReturn(chainHead);
    when(btcBlockStore.getStoredBlockAtMainChainHeight(block.getHeight())).thenReturn(block);
    BtcBlockStoreWithCache.Factory mockFactory = mock(BtcBlockStoreWithCache.Factory.class);
    when(mockFactory.newInstance(any(), any(), any(), any())).thenReturn(btcBlockStore);
    BridgeStorageProvider provider = spy(new BridgeStorageProvider(repository, contractAddress, bridgeConstants, activations));
    BridgeSupport bridgeSupport = getBridgeSupport(bridgeConstants, provider, repository, getBtcLockSenderProvider(TxSenderAddressType.P2SHP2WPKH, btcAddress, rskAddress), new PeginInstructionsProvider(), mock(Block.class), mockFactory, activations);
    CoinbaseInformation coinbaseInformation = new CoinbaseInformation(Sha256Hash.ZERO_HASH);
    provider.setCoinbaseInformation(registerHeader.getHash(), coinbaseInformation);
    bridgeSupport.registerBtcTransaction(mock(Transaction.class), tx1.bitcoinSerialize(), height, pmtWithWitness.bitcoinSerialize());
    verify(provider, never()).setHeightBtcTxhashAlreadyProcessed(tx1.getHash(true), height);
    verify(provider, never()).setHeightBtcTxhashAlreadyProcessed(any(Sha256Hash.class), anyLong());
}
Also used : RskAddress(co.rsk.core.RskAddress) ECKey(org.ethereum.crypto.ECKey) RskAddress(co.rsk.core.RskAddress) Script(co.rsk.bitcoinj.script.Script) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) CoinbaseInformation(co.rsk.peg.bitcoin.CoinbaseInformation) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) BigInteger(java.math.BigInteger) Block(org.ethereum.core.Block) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Example 39 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method registerFastBridgeBtcTransaction_surpasses_locking_cap_and_tries_to_register_again.

@Test
public void registerFastBridgeBtcTransaction_surpasses_locking_cap_and_tries_to_register_again() throws IOException, BlockStoreException, BridgeIllegalArgumentException {
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP176)).thenReturn(true);
    when(activations.isActive(ConsensusRule.RSKIP134)).thenReturn(true);
    Repository repository = createRepository();
    repository.addBalance(PrecompiledContracts.BRIDGE_ADDR, co.rsk.core.Coin.valueOf(1));
    BridgeStorageProvider provider = new BridgeStorageProvider(repository, PrecompiledContracts.BRIDGE_ADDR, bridgeConstants, activations);
    BtcLockSender btcLockSender = mock(BtcLockSender.class);
    BtcLockSenderProvider btcLockSenderProvider = mock(BtcLockSenderProvider.class);
    when(btcLockSenderProvider.tryGetBtcLockSender(any())).thenReturn(Optional.of(btcLockSender));
    Context btcContext = mock(Context.class);
    when(btcContext.getParams()).thenReturn(bridgeConstants.getBtcParams());
    BridgeSupport bridgeSupport = spy(new BridgeSupport(bridgeConstants, provider, mock(BridgeEventLogger.class), btcLockSenderProvider, new PeginInstructionsProvider(), repository, mock(Block.class), btcContext, mock(FederationSupport.class), mock(BtcBlockStoreWithCache.Factory.class), activations));
    doReturn(bridgeConstants.getGenesisFederation()).when(bridgeSupport).getActiveFederation();
    doReturn(true).when(bridgeSupport).validationsForRegisterBtcTransaction(any(), anyInt(), any(), any());
    doReturn(// The first time we simulate a lower locking cap than the value to register, to force the reimburse
    Coin.COIN, // The next time we simulate a hight locking cap, to verify the user can't attempt to register the already reimbursed tx
    Coin.FIFTY_COINS).when(bridgeSupport).getLockingCap();
    doReturn(PegTestUtils.createHash3(1)).when(bridgeSupport).getFastBridgeDerivationHash(any(Keccak256.class), any(Address.class), any(Address.class), any(RskAddress.class));
    Address btcAddress = Address.fromBase58(btcParams, "n3PLxDiwWqa5uH7fSbHCxS6VAjD9Y7Rwkj");
    ECKey key = ECKey.fromPublicOnly(new BtcECKey().getPubKey());
    RskAddress lbcAddress = new RskAddress(key.getAddress());
    BtcTransaction tx = createBtcTransactionWithOutputToAddress(Coin.COIN, getFastBridgeFederationAddress());
    byte[] pmtSerialized = Hex.decode("ab");
    InternalTransaction rskTx = new InternalTransaction(Keccak256.ZERO_HASH.getBytes(), 0, 0, null, null, null, lbcAddress.getBytes(), null, null, null, null);
    Keccak256 dHash = PegTestUtils.createHash3(0);
    BigInteger result = bridgeSupport.registerFastBridgeBtcTransaction(rskTx, tx.bitcoinSerialize(), 100, pmtSerialized, dHash, btcAddress, lbcAddress, btcAddress, false);
    Assert.assertEquals(BigInteger.valueOf(BridgeSupport.FAST_BRIDGE_REFUNDED_USER_ERROR_CODE), result);
    // Update repository
    bridgeSupport.save();
    result = bridgeSupport.registerFastBridgeBtcTransaction(rskTx, tx.bitcoinSerialize(), 100, pmtSerialized, dHash, btcAddress, lbcAddress, btcAddress, false);
    Assert.assertEquals(BigInteger.valueOf(BridgeSupport.FAST_BRIDGE_UNPROCESSABLE_TX_ALREADY_PROCESSED_ERROR_CODE), result);
}
Also used : RskAddress(co.rsk.core.RskAddress) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) ECKey(org.ethereum.crypto.ECKey) Keccak256(co.rsk.crypto.Keccak256) InternalTransaction(org.ethereum.vm.program.InternalTransaction) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) BtcLockSender(co.rsk.peg.btcLockSender.BtcLockSender) RskAddress(co.rsk.core.RskAddress) BigInteger(java.math.BigInteger) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Example 40 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method eventLoggerLogLockBtc_after_rskip_146_activation.

@Test
public void eventLoggerLogLockBtc_after_rskip_146_activation() throws Exception {
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
    BridgeEventLogger mockedEventLogger = mock(BridgeEventLogger.class);
    BridgeStorageProvider mockBridgeStorageProvider = mock(BridgeStorageProvider.class);
    when(mockBridgeStorageProvider.getHeightIfBtcTxhashIsAlreadyProcessed(any(Sha256Hash.class))).thenReturn(Optional.empty());
    LockWhitelist lockWhitelist = mock(LockWhitelist.class);
    when(lockWhitelist.isWhitelistedFor(any(Address.class), any(Coin.class), any(int.class))).thenReturn(true);
    when(mockBridgeStorageProvider.getLockWhitelist()).thenReturn(lockWhitelist);
    when(mockBridgeStorageProvider.getNewFederation()).thenReturn(bridgeConstants.getGenesisFederation());
    Block executionBlock = mock(Block.class);
    BtcBlockStoreWithCache.Factory btcBlockStoreFactory = mock(BtcBlockStoreWithCache.Factory.class);
    BtcBlockStoreWithCache btcBlockStore = mock(BtcBlockStoreWithCache.class);
    when(btcBlockStoreFactory.newInstance(any(Repository.class), any(), any(), any())).thenReturn(btcBlockStore);
    // Create transaction
    Coin lockValue = Coin.COIN;
    BtcTransaction tx = new BtcTransaction(bridgeConstants.getBtcParams());
    tx.addOutput(lockValue, mockBridgeStorageProvider.getNewFederation().getAddress());
    BtcECKey srcKey = new BtcECKey();
    tx.addInput(PegTestUtils.createHash(1), 0, ScriptBuilder.createInputScript(null, srcKey));
    // Create header and PMT
    byte[] bits = new byte[1];
    bits[0] = 0x3f;
    List<Sha256Hash> hashes = new ArrayList<>();
    hashes.add(tx.getHash());
    PartialMerkleTree pmt = new PartialMerkleTree(bridgeConstants.getBtcParams(), bits, hashes, 1);
    Sha256Hash merkleRoot = pmt.getTxnHashAndMerkleRoot(new ArrayList<>());
    co.rsk.bitcoinj.core.BtcBlock btcBlock = new co.rsk.bitcoinj.core.BtcBlock(bridgeConstants.getBtcParams(), 1, PegTestUtils.createHash(1), merkleRoot, 1, 1, 1, new ArrayList<>());
    int height = 1;
    mockChainOfStoredBlocks(btcBlockStore, btcBlock, height + bridgeConstants.getBtc2RskMinimumAcceptableConfirmations(), height);
    BridgeSupport bridgeSupport = bridgeSupportBuilder.withBridgeConstants(bridgeConstants).withProvider(mockBridgeStorageProvider).withEventLogger(mockedEventLogger).withBtcLockSenderProvider(new BtcLockSenderProvider()).withPeginInstructionsProvider(new PeginInstructionsProvider()).withExecutionBlock(executionBlock).withBtcBlockStoreFactory(btcBlockStoreFactory).withActivations(activations).build();
    bridgeSupport.registerBtcTransaction(mock(Transaction.class), tx.bitcoinSerialize(), height, pmt.bitcoinSerialize());
    verify(mockedEventLogger, atLeastOnce()).logLockBtc(any(RskAddress.class), any(BtcTransaction.class), any(Address.class), any(Coin.class));
}
Also used : RskAddress(co.rsk.core.RskAddress) BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) LockWhitelist(co.rsk.peg.whitelist.LockWhitelist) RskAddress(co.rsk.core.RskAddress) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) Block(org.ethereum.core.Block) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Aggregations

PeginInstructionsProvider (co.rsk.peg.pegininstructions.PeginInstructionsProvider)57 Test (org.junit.Test)51 BtcLockSenderProvider (co.rsk.peg.btcLockSender.BtcLockSenderProvider)50 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)49 RskAddress (co.rsk.core.RskAddress)44 Repository (org.ethereum.core.Repository)43 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)42 MutableRepository (org.ethereum.db.MutableRepository)42 Block (org.ethereum.core.Block)40 InternalTransaction (org.ethereum.vm.program.InternalTransaction)37 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)31 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)31 Transaction (org.ethereum.core.Transaction)31 ECKey (org.ethereum.crypto.ECKey)27 PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation (co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation)25 PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation (co.rsk.peg.PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation)25 Script (co.rsk.bitcoinj.script.Script)16 LockWhitelist (co.rsk.peg.whitelist.LockWhitelist)16 BigInteger (java.math.BigInteger)14 OneOffWhiteListEntry (co.rsk.peg.whitelist.OneOffWhiteListEntry)10