use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsProviderTest method extractOpReturnData_oneOpReturnForRskWithValue.
@Test
public void extractOpReturnData_oneOpReturnForRskWithValue() throws PeginInstructionsException {
// Arrange
Script opReturnScript = PegTestUtils.createOpReturnScriptForRsk(1, new RskAddress(new byte[20]), Optional.empty());
BtcTransaction btcTransaction = new BtcTransaction(params);
btcTransaction.addOutput(Coin.FIFTY_COINS, opReturnScript);
// Act
byte[] data = PeginInstructionsProvider.extractOpReturnData(btcTransaction);
// Assert
Assert.assertArrayEquals(opReturnScript.getChunks().get(1).data, data);
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsProviderTest method extractOpReturnData_oneOpReturnForRsk.
@Test
public void extractOpReturnData_oneOpReturnForRsk() throws PeginInstructionsException {
// Arrange
Script opReturnScript = PegTestUtils.createOpReturnScriptForRsk(1, new RskAddress(new byte[20]), Optional.empty());
BtcTransaction btcTransaction = new BtcTransaction(params);
btcTransaction.addOutput(Coin.ZERO, opReturnScript);
// Act
byte[] data = PeginInstructionsProvider.extractOpReturnData(btcTransaction);
// Assert
Assert.assertArrayEquals(opReturnScript.getChunks().get(1).data, data);
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsProviderTest method buildPeginInstructions_nullOpReturnData.
@Test
public void buildPeginInstructions_nullOpReturnData() throws Exception {
// Arrange
BtcTransaction btcTransaction = new BtcTransaction(params);
// Add OP_RETURN output with empty data
btcTransaction.addOutput(Coin.ZERO, new Script(new byte[] { ScriptOpCodes.OP_RETURN }));
// Act
PeginInstructionsProvider peginInstructionsProvider = new PeginInstructionsProvider();
Optional<PeginInstructions> peginInstructionsOptional = peginInstructionsProvider.buildPeginInstructions(btcTransaction);
// Assert
Assert.assertFalse(peginInstructionsOptional.isPresent());
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsProviderTest method buildPeginInstructions_v1_dataLengthDifferentThanSupported.
@Test(expected = PeginInstructionsParseException.class)
public void buildPeginInstructions_v1_dataLengthDifferentThanSupported() throws Exception {
// Arrange
int protocolVersion = 1;
BtcTransaction btcTransaction = new BtcTransaction(params);
Script opReturnScript = PegTestUtils.createOpReturnScriptForRskWithCustomPayload(protocolVersion, new byte[30]);
btcTransaction.addOutput(Coin.ZERO, opReturnScript);
// Act
PeginInstructionsProvider peginInstructionsProvider = new PeginInstructionsProvider();
peginInstructionsProvider.buildPeginInstructions(btcTransaction);
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsProviderTest method extractOpReturnData_noOpReturnForRsk.
@Test(expected = NoOpReturnException.class)
public void extractOpReturnData_noOpReturnForRsk() throws PeginInstructionsException {
// Arrange
Script opReturnScript = ScriptBuilder.createOpReturnScript("some-payload".getBytes());
BtcTransaction btcTransaction = new BtcTransaction(params);
btcTransaction.addOutput(Coin.ZERO, opReturnScript);
// Act
PeginInstructionsProvider.extractOpReturnData(btcTransaction);
}
Aggregations