Search in sources :

Example 46 with LogInfo

use of org.ethereum.vm.LogInfo in project rskj by rsksmart.

the class BridgeSupportReleaseBtcTest method handmade_release_after_rskip_146.

@Test
public void handmade_release_after_rskip_146() throws IOException {
    when(activationMock.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
    when(activationMock.isActive(ConsensusRule.RSKIP185)).thenReturn(false);
    List<LogInfo> logInfo = new ArrayList<>();
    BridgeEventLoggerImpl eventLogger = spy(new BridgeEventLoggerImpl(bridgeConstants, activationMock, logInfo));
    bridgeSupport = initBridgeSupport(eventLogger, activationMock);
    bridgeSupport.releaseBtc(releaseTx);
    Transaction rskTx = buildUpdateTx();
    rskTx.sign(new ECKey().getPrivKeyBytes());
    bridgeSupport.updateCollections(rskTx);
    verify(repository, never()).transfer(any(), any(), any());
    assertEquals(1, provider.getReleaseTransactionSet().getEntries().size());
    assertEquals(0, provider.getReleaseRequestQueue().getEntries().size());
    ReleaseTransactionSet.Entry entry = (ReleaseTransactionSet.Entry) provider.getReleaseTransactionSet().getEntries().toArray()[0];
    verify(eventLogger, times(1)).logReleaseBtcRequested(any(byte[].class), any(BtcTransaction.class), any(Coin.class));
}
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) ECKey(org.ethereum.crypto.ECKey) Test(org.junit.Test) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)

Example 47 with LogInfo

use of org.ethereum.vm.LogInfo in project rskj by rsksmart.

the class BridgeSupportReleaseBtcTest method handmade_release_after_rskip_146_rejected_lowAmount.

@Test
public void handmade_release_after_rskip_146_rejected_lowAmount() throws IOException {
    when(activationMock.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
    when(activationMock.isActive(ConsensusRule.RSKIP185)).thenReturn(false);
    List<LogInfo> logInfo = new ArrayList<>();
    BridgeEventLoggerImpl eventLogger = spy(new BridgeEventLoggerImpl(bridgeConstants, activationMock, logInfo));
    bridgeSupport = initBridgeSupport(eventLogger, activationMock);
    releaseTx = buildReleaseRskTx(Coin.ZERO);
    bridgeSupport.releaseBtc(releaseTx);
    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()).logReleaseBtcRequestRejected(any(), any(), any());
    assertEquals(1, logInfo.size());
    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 48 with LogInfo

use of org.ethereum.vm.LogInfo 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 49 with LogInfo

use of org.ethereum.vm.LogInfo 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 50 with LogInfo

use of org.ethereum.vm.LogInfo in project rskj by rsksmart.

the class TransactionReceipt method getEncoded.

/* [postTxState, cumulativeGas, bloomFilter, logInfoList] */
public byte[] getEncoded() {
    if (rlpEncoded != null) {
        return rlpEncoded;
    }
    byte[] postTxStateRLP = RLP.encodeElement(this.postTxState);
    byte[] cumulativeGasRLP = RLP.encodeElement(this.cumulativeGas);
    byte[] gasUsedRLP = RLP.encodeElement(this.gasUsed);
    byte[] bloomRLP = RLP.encodeElement(this.bloomFilter.getData());
    byte[] statusRLP = RLP.encodeElement(this.status);
    final byte[] logInfoListRLP;
    if (logInfoList != null) {
        byte[][] logInfoListE = new byte[logInfoList.size()][];
        int i = 0;
        for (LogInfo logInfo : logInfoList) {
            logInfoListE[i] = logInfo.getEncoded();
            ++i;
        }
        logInfoListRLP = RLP.encodeList(logInfoListE);
    } else {
        logInfoListRLP = RLP.encodeList();
    }
    rlpEncoded = RLP.encodeList(postTxStateRLP, cumulativeGasRLP, bloomRLP, logInfoListRLP, gasUsedRLP, statusRLP);
    return rlpEncoded;
}
Also used : LogInfo(org.ethereum.vm.LogInfo)

Aggregations

LogInfo (org.ethereum.vm.LogInfo)74 DataWord (org.ethereum.vm.DataWord)36 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)25 CallTransaction (org.ethereum.core.CallTransaction)23 Transaction (org.ethereum.core.Transaction)17 RskAddress (co.rsk.core.RskAddress)13 BridgeEventLoggerImpl (co.rsk.peg.utils.BridgeEventLoggerImpl)12 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)11 InternalTransaction (org.ethereum.vm.program.InternalTransaction)11 Block (org.ethereum.core.Block)9 Repository (org.ethereum.core.Repository)9 RepositoryImpl (co.rsk.db.RepositoryImpl)8 Keccak256 (co.rsk.crypto.Keccak256)7 BigInteger (java.math.BigInteger)7 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)7 RLPList (org.ethereum.util.RLPList)6 LinkedList (java.util.LinkedList)4 RLPElement (org.ethereum.util.RLPElement)4 Coin (co.rsk.core.Coin)3