Skip to content

Commit

Permalink
naming refactor
Browse files Browse the repository at this point in the history
fix cucumber
  • Loading branch information
SWvheerden committed Nov 10, 2021
1 parent f1b650d commit e0a5b50
Show file tree
Hide file tree
Showing 9 changed files with 4,452 additions and 427 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub async fn init_sha_atomic_swap(
let (fee_per_gram, amount, dest_pubkey, message) = get_init_sha_atomic_swap_parameters(args)?;

let (tx_id, pre_image, output) = wallet_transaction_service
.broadcast_sha_atomic_swap_transaction(dest_pubkey, amount, fee_per_gram, message)
.send_sha_atomic_swap_transaction(dest_pubkey, amount, fee_per_gram, message)
.await
.map_err(CommandError::TransactionServiceError)?;
Ok((tx_id, pre_image, output))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl wallet_server::Wallet for WalletGrpcServer {

let mut transaction_service = self.get_transaction_service();
let response = match transaction_service
.broadcast_sha_atomic_swap_transaction(
.send_sha_atomic_swap_transaction(
address.clone(),
message.amount.into(),
message.fee_per_gram.into(),
Expand Down
8 changes: 4 additions & 4 deletions base_layer/wallet/src/output_manager_service/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub enum OutputManagerRequest {
ReinstateCancelledInboundTx(TxId),
SetCoinbaseAbandoned(TxId, bool),
CreateClaimShaAtomicSwapTransaction(HashOutput, PublicKey, MicroTari),
CreateClaimHTLCSwapTransaction(Box<(TransactionOutput, PublicKey, MicroTari)>),
CreateClaimShaSwapTransaction(Box<(TransactionOutput, PublicKey, MicroTari)>),
}

impl fmt::Display for OutputManagerRequest {
Expand Down Expand Up @@ -135,7 +135,7 @@ impl fmt::Display for OutputManagerRequest {
pre_image,
fee_per_gram,
),
CreateClaimHTLCSwapTransaction(boxed) => {
CreateClaimShaSwapTransaction(boxed) => {
let (output, pre_image, fee_per_gram) = &**boxed;
write!(
f,
Expand Down Expand Up @@ -451,15 +451,15 @@ impl OutputManagerHandle {
}
}

pub async fn create_claim_htlc_transaction(
pub async fn create_claim_sha_atomic_swap_transaction_with_output(
&mut self,
output: TransactionOutput,
pre_image: PublicKey,
fee_per_gram: MicroTari,
) -> Result<(u64, MicroTari, MicroTari, Transaction), OutputManagerError> {
match self
.handle
.call(OutputManagerRequest::CreateClaimHTLCSwapTransaction(Box::new((
.call(OutputManagerRequest::CreateClaimShaSwapTransaction(Box::new((
output,
pre_image,
fee_per_gram,
Expand Down
2 changes: 1 addition & 1 deletion base_layer/wallet/src/output_manager_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ where
.await
.map(OutputManagerResponse::ClaimShaAtomicSwapTransaction)
},
OutputManagerRequest::CreateClaimHTLCSwapTransaction(boxed) => {
OutputManagerRequest::CreateClaimShaSwapTransaction(boxed) => {
let (output, pre_image, fee_per_gram) = *boxed;
self.create_claim_sha_atomic_swap_transaction(output, pre_image, fee_per_gram)
.await
Expand Down
10 changes: 5 additions & 5 deletions base_layer/wallet/src/transaction_service/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub enum TransactionServiceRequest {
GetAnyTransaction(TxId),
SendTransaction(CommsPublicKey, MicroTari, MicroTari, String),
SendOneSidedTransaction(CommsPublicKey, MicroTari, MicroTari, String),
BroadcastShaAtomicSwapTransaction(CommsPublicKey, MicroTari, MicroTari, String),
SendShaAtomicSwapTransaction(CommsPublicKey, MicroTari, MicroTari, String),
CancelTransaction(TxId),
ImportUtxo(MicroTari, CommsPublicKey, String, Option<u64>),
SubmitTransactionToSelf(TxId, Transaction, MicroTari, MicroTari, String),
Expand Down Expand Up @@ -80,8 +80,8 @@ impl fmt::Display for TransactionServiceRequest {
Self::SendOneSidedTransaction(k, v, _, msg) => {
f.write_str(&format!("SendOneSidedTransaction (to {}, {}, {})", k, v, msg))
},
Self::BroadcastShaAtomicSwapTransaction(k, v, _, msg) => {
f.write_str(&format!("BroadcastShaAtomicSwapTransaction (to {}, {}, {})", k, v, msg))
Self::SendShaAtomicSwapTransaction(k, v, _, msg) => {
f.write_str(&format!("SendShaAtomicSwapTransaction (to {}, {}, {})", k, v, msg))
},
Self::CancelTransaction(t) => f.write_str(&format!("CancelTransaction ({})", t)),
Self::ImportUtxo(v, k, msg, maturity) => f.write_str(&format!(
Expand Down Expand Up @@ -519,7 +519,7 @@ impl TransactionServiceHandle {
}
}

pub async fn broadcast_sha_atomic_swap_transaction(
pub async fn send_sha_atomic_swap_transaction(
&mut self,
dest_pubkey: CommsPublicKey,
amount: MicroTari,
Expand All @@ -528,7 +528,7 @@ impl TransactionServiceHandle {
) -> Result<(TxId, PublicKey, TransactionOutput), TransactionServiceError> {
match self
.handle
.call(TransactionServiceRequest::BroadcastShaAtomicSwapTransaction(
.call(TransactionServiceRequest::SendShaAtomicSwapTransaction(
dest_pubkey,
amount,
fee_per_gram,
Expand Down
29 changes: 13 additions & 16 deletions base_layer/wallet/src/transaction_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,21 +557,18 @@ where
)
.await
.map(TransactionServiceResponse::TransactionSent),
TransactionServiceRequest::BroadcastShaAtomicSwapTransaction(
dest_pubkey,
amount,
fee_per_gram,
message,
) => Ok(TransactionServiceResponse::ShaAtomicSwapTransactionSent(
self.broadcast_sha_atomic_swap_transaction(
dest_pubkey,
amount,
fee_per_gram,
message,
transaction_broadcast_join_handles,
)
.await?,
)),
TransactionServiceRequest::SendShaAtomicSwapTransaction(dest_pubkey, amount, fee_per_gram, message) => {
Ok(TransactionServiceResponse::ShaAtomicSwapTransactionSent(
self.send_sha_atomic_swap_transaction(
dest_pubkey,
amount,
fee_per_gram,
message,
transaction_broadcast_join_handles,
)
.await?,
))
},
TransactionServiceRequest::CancelTransaction(tx_id) => self
.cancel_pending_transaction(tx_id)
.await
Expand Down Expand Up @@ -806,7 +803,7 @@ where
/// 'dest_pubkey': The Comms pubkey of the recipient node
/// 'amount': The amount of Tari to send to the recipient
/// 'fee_per_gram': The amount of fee per transaction gram to be included in transaction
pub async fn broadcast_sha_atomic_swap_transaction(
pub async fn send_sha_atomic_swap_transaction(
&mut self,
dest_pubkey: CommsPublicKey,
amount: MicroTari,
Expand Down
4 changes: 2 additions & 2 deletions base_layer/wallet/tests/transaction_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ fn test_htlc_send_and_claim() {
let mut alice_ts_clone = alice_ts.clone();
let (tx_id, pre_image, output) = runtime.block_on(async move {
alice_ts_clone
.broadcast_sha_atomic_swap_transaction(
.send_sha_atomic_swap_transaction(
bob_node_identity.public_key().clone(),
value,
20.into(),
Expand Down Expand Up @@ -1035,7 +1035,7 @@ fn test_htlc_send_and_claim() {

runtime.block_on(async move {
let (tx_id_htlc, htlc_fee, htlc_amount, tx) = bob_oms
.create_claim_htlc_transaction(output, pre_image, 20.into())
.create_claim_sha_atomic_swap_transaction_with_output(output, pre_image, 20.into())
.await
.unwrap();

Expand Down
5 changes: 1 addition & 4 deletions integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ When(
/mining node (.*) mines (\d+) blocks$/,
{ timeout: 1200 * 1000 }, // Must allow many blocks to be mined; dynamic time out below limits actual time
async function (miner, numBlocks) {
const miningNode = this.getMiningNode(miner);d
const miningNode = this.getMiningNode(miner);
// Don't wait for sync before mining. Also use a max difficulty of 1, since most tests assume
// that 1 block = 1 difficulty
await miningNode.init(numBlocks, null, 1, 1, false, null);
Expand Down Expand Up @@ -1930,7 +1930,6 @@ When(
);
}
expect(success).to.equal(true);
console.log("hello1");
//lets now wait for this transaction to be at least broadcast before we continue.
await waitFor(
async () =>
Expand All @@ -1943,12 +1942,10 @@ When(
5
);

console.log("hello2");
let transactionPending = await sourceClient.isTransactionAtLeastBroadcast(
this.lastResult.results.transaction_id
);

console.log("hello3");
expect(transactionPending).to.equal(true);
}
);
Expand Down
Loading

0 comments on commit e0a5b50

Please sign in to comment.