Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration_tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ const DEPOSIT_FEE: bitcoin::Amount = bitcoin::Amount::from_sat(1_000_000);
pub async fn deposit<S>(
post_setup: &mut PostSetup,
sidechain: &mut S,
sidechain_address: &str,
sidechain_address: &[u8],
deposit_amount: bitcoin::Amount,
deposit_fee: bitcoin::Amount,
) -> anyhow::Result<()>
Expand All @@ -628,7 +628,7 @@ where
.wallet_service_client
.create_deposit_transaction(CreateDepositTransactionRequest {
sidechain_id: proto::wrap_u32(S::SIDECHAIN_NUMBER.0.into()),
address: proto::wrap_string(sidechain_address.to_owned()),
sidechain_address: proto::wrap_sidechain_address(sidechain_address),
value_sats: proto::wrap_u64(deposit_amount.to_sat()),
fee_sats: proto::wrap_u64(deposit_fee.to_sat()),
})
Expand Down
10 changes: 5 additions & 5 deletions integration_tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,14 +1698,14 @@ pub trait Sidechain: Sized {
/// Get a sidechain address to deposit to
fn get_deposit_address(
&self,
) -> impl Future<Output = Result<String, Self::GetDepositAddressError>> + Send;
) -> impl Future<Output = Result<Vec<u8>, Self::GetDepositAddressError>> + Send;

type ConfirmDepositError: std::error::Error + Send + Sync + 'static;

fn confirm_deposit(
&mut self,
post_setup: &mut PostSetup,
address: &str,
sidechain_address: &[u8],
value: bitcoin::Amount,
txid: bitcoin::Txid,
) -> impl Future<Output = Result<(), Self::ConfirmDepositError>> + Send;
Expand Down Expand Up @@ -2009,16 +2009,16 @@ impl Sidechain for DummySidechain {

fn get_deposit_address(
&self,
) -> impl Future<Output = Result<String, Self::GetDepositAddressError>> + Send {
future::ok("sidechain address".to_owned())
) -> impl Future<Output = Result<Vec<u8>, Self::GetDepositAddressError>> + Send {
future::ok("sidechain address".as_bytes().to_owned())
}

type ConfirmDepositError = std::convert::Infallible;

async fn confirm_deposit(
&mut self,
_: &mut PostSetup,
_: &str,
_: &[u8],
_: bitcoin::Amount,
_: bitcoin::Txid,
) -> Result<(), Self::ConfirmDepositError> {
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/test_consecutive_deposits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const DEPOSIT_FEE: bitcoin::Amount = bitcoin::Amount::from_sat(1_000_000);
/// Create a deposit via the wallet gRPC, without mining a block.
async fn create_deposit(
post_setup: &mut PostSetup,
sidechain_address: &str,
sidechain_address: &[u8],
) -> anyhow::Result<bitcoin::Txid> {
let deposit_txid = post_setup
.wallet_service_client
.create_deposit_transaction(CreateDepositTransactionRequest {
sidechain_id: proto::wrap_u32(DummySidechain::SIDECHAIN_NUMBER.0.into()),
address: proto::wrap_string(sidechain_address),
sidechain_address: proto::wrap_sidechain_address(sidechain_address),
value_sats: proto::wrap_u64(DEPOSIT_AMOUNT.to_sat()),
fee_sats: proto::wrap_u64(DEPOSIT_FEE.to_sat()),
})
Expand Down Expand Up @@ -139,14 +139,14 @@ pub async fn test_consecutive_deposits(mut post_setup: PostSetup) -> anyhow::Res
tracing::info!("Consolidated wallet into a single UTXO");

// First deposit: always succeeds, spending the sole UTXO.
let deposit_txid_1 = create_deposit(&mut post_setup, "sidechain address 1").await?;
let deposit_txid_1 = create_deposit(&mut post_setup, b"sidechain address 1").await?;
tracing::info!(%deposit_txid_1, "Created first deposit");
let () = wait_for_tx_in_mempool(&post_setup.bitcoind_client, &deposit_txid_1).await?;

// Second deposit, without a block in between. This must succeed: it should
// be funded from the first deposit's change output, not by reselecting the
// first deposit's (now spent) input.
let deposit_txid_2 = create_deposit(&mut post_setup, "sidechain address 2")
let deposit_txid_2 = create_deposit(&mut post_setup, b"sidechain address 2")
.await
.map_err(|err| {
anyhow::anyhow!(
Expand Down
1 change: 0 additions & 1 deletion integration_tests/test_peer_bmm_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ async fn test_peer_bmm_request_task(mut post_setup: PostSetup) -> anyhow::Result
height: tip_height,
work: _,
timestamp: _,
..
} = post_setup
.sender
.validator_service_client
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/test_peer_deposit_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const SENDER_FUNDING: bitcoin::Amount = bitcoin::Amount::from_sat(100_000_000);
const DEPOSIT_AMOUNT: bitcoin::Amount = bitcoin::Amount::from_sat(21_000_000);
const DEPOSIT_FEE: bitcoin::Amount = bitcoin::Amount::from_sat(1_000_000);

const SIDECHAIN_ADDRESS: &str = "peer relay sidechain address";
const SIDECHAIN_ADDRESS: &[u8] = b"peer relay sidechain address";

struct Directories<'a> {
/// Mines the blocks
Expand Down Expand Up @@ -403,7 +403,7 @@ async fn test_peer_deposit_relay_task(mut post_setup: PostSetup) -> anyhow::Resu
.wallet_service_client
.create_deposit_transaction(CreateDepositTransactionRequest {
sidechain_id: proto::wrap_u32(DummySidechain::SIDECHAIN_NUMBER.0.into()),
address: proto::wrap_string(SIDECHAIN_ADDRESS),
sidechain_address: proto::wrap_sidechain_address(SIDECHAIN_ADDRESS),
value_sats: proto::wrap_u64(DEPOSIT_AMOUNT.to_sat()),
fee_sats: proto::wrap_u64(DEPOSIT_FEE.to_sat()),
})
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_withdrawal_payout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async fn pending_bundles(post_setup: &PostSetup) -> anyhow::Result<usize> {
/// which must be kept alive, and its deposit address.
async fn activate_funded_sidechain(
post_setup: &mut PostSetup,
) -> anyhow::Result<(DummySidechain, String)> {
) -> anyhow::Result<(DummySidechain, Vec<u8>)> {
let (sidechain_res_tx, _sidechain_res_rx) = mpsc::unbounded();
let mut sidechain = DummySidechain::setup((), post_setup, sidechain_res_tx).await?;
let () = propose_sidechain::<DummySidechain>(post_setup).await?;
Expand Down
7 changes: 7 additions & 0 deletions lib/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ impl From<Error> for ConnectError {
}
}

pub fn wrap_sidechain_address<T>(sidechain_address: T) -> MessageField<Hex, Inline<Hex>>
where
T: hex::ToHex,
{
MessageField::some(Hex::encode(&sidechain_address))
}

pub fn wrap_string(value: impl Into<String>) -> MessageField<StringValue, Inline<StringValue>> {
MessageField::some(StringValue {
value: value.into(),
Expand Down
87 changes: 44 additions & 43 deletions lib/proto/generated/buffa/cusf.common.v1.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading