use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class BridgeEventLoggerImpl method logAddSignatureInSolidityFormat.
private void logAddSignatureInSolidityFormat(byte[] rskTxHash, String federatorRskAddress, BtcECKey federatorPublicKey) {
CallTransaction.Function event = BridgeEvents.ADD_SIGNATURE.getEvent();
byte[][] encodedTopicsInBytes = event.encodeEventTopics(rskTxHash, federatorRskAddress);
List<DataWord> encodedTopics = LogInfo.byteArrayToList(encodedTopicsInBytes);
byte[] encodedData = event.encodeEventData(federatorPublicKey.getPubKey());
this.logs.add(new LogInfo(BRIDGE_CONTRACT_ADDRESS, encodedTopics, encodedData));
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class BridgeEventLoggerImpl method logReleaseBtcInRLPFormat.
private void logReleaseBtcInRLPFormat(BtcTransaction btcTx) {
List<DataWord> topics = Collections.singletonList(Bridge.RELEASE_BTC_TOPIC);
byte[] data = RLP.encodeList(RLP.encodeString(btcTx.getHashAsString()), RLP.encodeElement(btcTx.bitcoinSerialize()));
this.logs.add(new LogInfo(BRIDGE_CONTRACT_ADDRESS, topics, data));
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class BridgeSupportReleaseBtcTest method handmade_release_after_rskip_146_rejected_contractCaller.
@Test
public void handmade_release_after_rskip_146_rejected_contractCaller() throws IOException {
when(activationMock.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
when(activationMock.isActive(ConsensusRule.RSKIP185)).thenReturn(false);
List<LogInfo> logInfo = new ArrayList<>();
BridgeEventLoggerImpl eventLogger = new BridgeEventLoggerImpl(bridgeConstants, activationMock, logInfo);
bridgeSupport = initBridgeSupport(eventLogger, activationMock);
releaseTx = buildReleaseRskTx_fromContract(Coin.COIN);
try {
bridgeSupport.releaseBtc(releaseTx);
fail();
} catch (Program.OutOfGasException e) {
assertTrue(e.getMessage().contains("Contract calling releaseBTC"));
}
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class BridgeSupportReleaseBtcTest method handmade_release_after_rskip_146_185.
@Test
public void handmade_release_after_rskip_146_185() 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);
bridgeSupport.releaseBtc(releaseTx);
Transaction rskTx = buildUpdateTx();
rskTx.sign(SENDER.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];
assertEquals(3, logInfo.size());
verify(eventLogger, times(1)).logReleaseBtcRequested(any(byte[].class), any(BtcTransaction.class), any(Coin.class));
verify(eventLogger, times(1)).logReleaseBtcRequestReceived(any(), any(), any());
verify(eventLogger, times(1)).logUpdateCollections(any());
}
use of org.ethereum.vm.LogInfo in project rskj by rsksmart.
the class BridgeSupportReleaseBtcTest method release_after_rskip_219.
@Test
public void release_after_rskip_219() throws IOException {
when(activationMock.isActive(ConsensusRule.RSKIP146)).thenReturn(true);
when(activationMock.isActive(ConsensusRule.RSKIP185)).thenReturn(true);
when(activationMock.isActive(ConsensusRule.RSKIP219)).thenReturn(true);
List<LogInfo> logInfo = new ArrayList<>();
BridgeEventLoggerImpl eventLogger = spy(new BridgeEventLoggerImpl(bridgeConstants, activationMock, logInfo));
bridgeSupport = initBridgeSupport(eventLogger, activationMock);
// Get a value between old and new minimum pegout values
Coin middle = bridgeConstants.getLegacyMinimumPegoutTxValueInSatoshis().subtract(bridgeConstants.getMinimumPegoutTxValueInSatoshis()).div(2);
Coin value = bridgeConstants.getMinimumPegoutTxValueInSatoshis().add(middle);
assertTrue(value.isLessThan(bridgeConstants.getLegacyMinimumPegoutTxValueInSatoshis()));
assertTrue(value.isGreaterThan(bridgeConstants.getMinimumPegoutTxValueInSatoshis()));
bridgeSupport.releaseBtc(buildReleaseRskTx(value));
Transaction rskTx = buildUpdateTx();
rskTx.sign(SENDER.getPrivKeyBytes());
verify(repository, never()).transfer(any(), any(), any());
assertEquals(1, provider.getReleaseRequestQueue().getEntries().size());
assertEquals(1, logInfo.size());
verify(eventLogger, times(1)).logReleaseBtcRequestReceived(any(), any(), any());
}
Aggregations