Search in sources :

Example 11 with BridgeEventLoggerImpl

use of co.rsk.peg.utils.BridgeEventLoggerImpl in project rskj by rsksmart.

the class BridgeSupportReleaseBtcTest method handmade_release_after_rskip_146_185_rejected_contractCaller.

@Test
public void handmade_release_after_rskip_146_185_rejected_contractCaller() throws IOException {
    when(activationMock.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
    when(activationMock.isActive(ConsensusRule.RSKIP185)).thenReturn(true);
    List<LogInfo> logInfo = new ArrayList<>();
    BridgeEventLoggerImpl eventLogger = spy(new BridgeEventLoggerImpl(bridgeConstants, activationMock, logInfo));
    bridgeSupport = initBridgeSupport(eventLogger, activationMock);
    releaseTx = buildReleaseRskTx_fromContract(Coin.COIN);
    bridgeSupport.releaseBtc(releaseTx);
    // Create Contract transaction
    Transaction rskTx = buildUpdateTx();
    rskTx.sign(SENDER.getPrivKeyBytes());
    bridgeSupport.updateCollections(rskTx);
    verify(repository, never()).transfer(any(), any(), any());
    assertEquals(0, provider.getReleaseTransactionSet().getEntries().size());
    assertEquals(0, provider.getReleaseRequestQueue().getEntries().size());
    verify(eventLogger, never()).logReleaseBtcRequestReceived(any(), any(), any());
    assertEquals(2, logInfo.size());
    verify(eventLogger, times(1)).logReleaseBtcRequestRejected(any(), any(), any());
    verify(eventLogger, times(1)).logUpdateCollections(any());
}
Also used : BridgeEventLoggerImpl(co.rsk.peg.utils.BridgeEventLoggerImpl) LogInfo(org.ethereum.vm.LogInfo) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) ArrayList(java.util.ArrayList) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 12 with BridgeEventLoggerImpl

use of co.rsk.peg.utils.BridgeEventLoggerImpl in project rskj by rsksmart.

the class BridgeSupportReleaseBtcTest method release_before_rskip_219_minimum_exclusive.

@Test
public void release_before_rskip_219_minimum_exclusive() throws IOException {
    when(activationMock.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
    when(activationMock.isActive(ConsensusRule.RSKIP185)).thenReturn(true);
    when(activationMock.isActive(ConsensusRule.RSKIP219)).thenReturn(false);
    List<LogInfo> logInfo = new ArrayList<>();
    BridgeEventLoggerImpl eventLogger = spy(new BridgeEventLoggerImpl(bridgeConstants, activationMock, logInfo));
    bridgeSupport = initBridgeSupport(eventLogger, activationMock);
    // Get a value exactly to legacy minimum
    Coin value = bridgeConstants.getLegacyMinimumPegoutTxValueInSatoshis();
    bridgeSupport.releaseBtc(buildReleaseRskTx(value));
    Transaction rskTx = buildUpdateTx();
    rskTx.sign(SENDER.getPrivKeyBytes());
    assertEquals(0, provider.getReleaseRequestQueue().getEntries().size());
    assertEquals(1, logInfo.size());
    verify(eventLogger, never()).logReleaseBtcRequestReceived(any(), any(), any());
    verify(eventLogger, times(1)).logReleaseBtcRequestRejected(any(), any(), any());
}
Also used : BridgeEventLoggerImpl(co.rsk.peg.utils.BridgeEventLoggerImpl) LogInfo(org.ethereum.vm.LogInfo) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) ArrayList(java.util.ArrayList) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 13 with BridgeEventLoggerImpl

use of co.rsk.peg.utils.BridgeEventLoggerImpl in project rskj by rsksmart.

the class BridgeSupportFactory method newInstance.

public BridgeSupport newInstance(Repository repository, Block executionBlock, RskAddress contractAddress, List<LogInfo> logs) {
    ActivationConfig.ForBlock activations = activationConfig.forBlock(executionBlock.getNumber());
    Context btcContext = new Context(bridgeConstants.getBtcParams());
    BridgeStorageProvider provider = new BridgeStorageProvider(repository, contractAddress, bridgeConstants, activations);
    FederationSupport federationSupport = new FederationSupport(bridgeConstants, provider, executionBlock);
    BridgeEventLogger eventLogger;
    if (logs == null) {
        eventLogger = null;
    } else {
        eventLogger = new BridgeEventLoggerImpl(bridgeConstants, activations, logs);
    }
    BtcLockSenderProvider btcLockSenderProvider = new BtcLockSenderProvider();
    PeginInstructionsProvider peginInstructionsProvider = new PeginInstructionsProvider();
    return new BridgeSupport(bridgeConstants, provider, eventLogger, btcLockSenderProvider, peginInstructionsProvider, repository, executionBlock, btcContext, federationSupport, btcBlockStoreFactory, activations);
}
Also used : Context(co.rsk.bitcoinj.core.Context) BridgeEventLoggerImpl(co.rsk.peg.utils.BridgeEventLoggerImpl) BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) BridgeEventLogger(co.rsk.peg.utils.BridgeEventLogger)

Aggregations

BridgeEventLoggerImpl (co.rsk.peg.utils.BridgeEventLoggerImpl)13 LogInfo (org.ethereum.vm.LogInfo)12 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)10 Transaction (org.ethereum.core.Transaction)10 InternalTransaction (org.ethereum.vm.program.InternalTransaction)10 BridgeEventLogger (co.rsk.peg.utils.BridgeEventLogger)3 ECKey (org.ethereum.crypto.ECKey)3 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)2 BtcLockSenderProvider (co.rsk.peg.btcLockSender.BtcLockSenderProvider)2 PeginInstructionsProvider (co.rsk.peg.pegininstructions.PeginInstructionsProvider)2 RejectedPegoutReason (co.rsk.peg.utils.RejectedPegoutReason)2 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)2 Program (org.ethereum.vm.program.Program)2 Context (co.rsk.bitcoinj.core.Context)1 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)1 BridgeConstants (co.rsk.config.BridgeConstants)1 BridgeRegTestConstants (co.rsk.config.BridgeRegTestConstants)1 RskAddress (co.rsk.core.RskAddress)1