From 71a0832ef470c2190113b801143c398fc5495d49 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 7 Dec 2020 15:32:40 +1100 Subject: [PATCH] Add zero const to monero::Amount --- swap/tests/e2e.rs | 4 ++-- xmr-btc/src/monero.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/swap/tests/e2e.rs b/swap/tests/e2e.rs index debebcbe..b42203bc 100644 --- a/swap/tests/e2e.rs +++ b/swap/tests/e2e.rs @@ -37,7 +37,7 @@ async fn happy_path() { // 10_000 * 100 let xmr_to_swap = xmr_btc::monero::Amount::from_piconero(1_000_000_000_000); let xmr_alice = xmr_to_swap * 10; - let xmr_bob = xmr_btc::monero::Amount::from_piconero(0); + let xmr_bob = xmr_btc::monero::Amount::ZERO; // todo: This should not be hardcoded let alice_multiaddr: Multiaddr = "/ip4/127.0.0.1/tcp/9876" @@ -142,7 +142,7 @@ async fn alice_punishes_if_bob_never_acts_after_fund() { let xmr_to_swap = xmr_btc::monero::Amount::from_piconero(1_000_000_000_000); let bob_btc_starting_balance = btc_to_swap * 10; - let bob_xmr_starting_balance = xmr_btc::monero::Amount::from_piconero(0); + let bob_xmr_starting_balance = xmr_btc::monero::Amount::ZERO; let alice_btc_starting_balance = bitcoin::Amount::ZERO; let alice_xmr_starting_balance = xmr_to_swap * 10; diff --git a/xmr-btc/src/monero.rs b/xmr-btc/src/monero.rs index 859da380..31deb392 100644 --- a/xmr-btc/src/monero.rs +++ b/xmr-btc/src/monero.rs @@ -76,6 +76,7 @@ pub struct PublicViewKey(PublicKey); pub struct Amount(u64); impl Amount { + pub const ZERO: Self = Self(0); /// Create an [Amount] with piconero precision and the given number of /// piconeros. ///