-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3911 from ripcurlx/redact-deposittxid-from-trades…
…tatistics Redact deposittxid from tradestatistics
- Loading branch information
Showing
8 changed files
with
186 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
core/src/test/java/bisq/core/trade/statistics/TradeStatistics2Maker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.core.trade.statistics; | ||
|
||
import bisq.core.monetary.Price; | ||
import bisq.core.offer.OfferPayload; | ||
|
||
import org.bitcoinj.core.Coin; | ||
|
||
import java.util.Calendar; | ||
import java.util.Collections; | ||
import java.util.Date; | ||
|
||
import com.natpryce.makeiteasy.Instantiator; | ||
import com.natpryce.makeiteasy.Maker; | ||
import com.natpryce.makeiteasy.Property; | ||
|
||
import static com.natpryce.makeiteasy.MakeItEasy.a; | ||
|
||
public class TradeStatistics2Maker { | ||
|
||
public static final Property<TradeStatistics2, Date> date = new Property<>(); | ||
public static final Property<TradeStatistics2, String> depositTxId = new Property<>(); | ||
|
||
public static final Instantiator<TradeStatistics2> TradeStatistic2 = lookup -> { | ||
Calendar calendar = Calendar.getInstance(); | ||
calendar.set(2016, 3, 19); | ||
|
||
return new TradeStatistics2( | ||
new OfferPayload("1234", | ||
0L, | ||
null, | ||
null, | ||
OfferPayload.Direction.BUY, | ||
100000L, | ||
0.0, | ||
false, | ||
100000L, | ||
100000L, | ||
"BTC", | ||
"USD", | ||
null, | ||
null, | ||
"SEPA", | ||
"", | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
"", | ||
0L, | ||
0L, | ||
0L, | ||
false, | ||
0L, | ||
0L, | ||
0L, | ||
0L, | ||
false, | ||
false, | ||
0L, | ||
0L, | ||
false, | ||
null, | ||
null, | ||
0), | ||
Price.valueOf("BTC", 100000L), | ||
Coin.SATOSHI, | ||
lookup.valueOf(date, new Date(calendar.getTimeInMillis())), | ||
lookup.valueOf(depositTxId, "123456"), | ||
Collections.emptyMap()); | ||
}; | ||
public static final Maker<TradeStatistics2> dayZeroTrade = a(TradeStatistic2); | ||
} |
62 changes: 62 additions & 0 deletions
62
core/src/test/java/bisq/core/trade/statistics/TradeStatistics2Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.core.trade.statistics; | ||
|
||
import org.apache.commons.lang3.time.DateUtils; | ||
|
||
import org.junit.Test; | ||
|
||
import static bisq.core.trade.statistics.TradeStatistics2Maker.date; | ||
import static bisq.core.trade.statistics.TradeStatistics2Maker.dayZeroTrade; | ||
import static bisq.core.trade.statistics.TradeStatistics2Maker.depositTxId; | ||
import static com.natpryce.makeiteasy.MakeItEasy.make; | ||
import static com.natpryce.makeiteasy.MakeItEasy.with; | ||
import static com.natpryce.makeiteasy.MakeItEasy.withNull; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
|
||
public class TradeStatistics2Test { | ||
|
||
@Test | ||
public void isValid_WithDepositTxIdBeforeCutOffDate() { | ||
|
||
TradeStatistics2 tradeStatistic = make(dayZeroTrade); | ||
|
||
assertTrue(tradeStatistic.isValid()); | ||
} | ||
|
||
@Test | ||
public void isValid_Not_WithDepositTxIdAfterCutOffDate() { | ||
TradeStatistics2 tradeStatistic = make(dayZeroTrade.but( | ||
with(date, DateUtils.addDays(TradeStatistics2.CUT_OFF_DATE_FOR_DEPOSIT_TX_ID, 1)) | ||
)); | ||
|
||
assertFalse(tradeStatistic.isValid()); | ||
} | ||
|
||
@Test | ||
public void isValid_WithEmptyDepositTxIdAfterCutOffDate() { | ||
TradeStatistics2 tradeStatistic = make(dayZeroTrade.but( | ||
with(date, DateUtils.addDays(TradeStatistics2.CUT_OFF_DATE_FOR_DEPOSIT_TX_ID, 1)), | ||
withNull(depositTxId) | ||
)); | ||
|
||
assertTrue(tradeStatistic.isValid()); | ||
} | ||
} |
Oops, something went wrong.