mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-03 10:46:54 +01:00
Add tests for blockchain URLs
This commit is contained in:
parent
4ae5d55000
commit
9ee3d34aa9
1 changed files with 48 additions and 2 deletions
|
@ -23,6 +23,7 @@ import bisq.core.locale.TradeCurrency;
|
|||
import bisq.core.monetary.Price;
|
||||
import bisq.core.provider.price.MarketPrice;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.user.BlockChainExplorer;
|
||||
import bisq.core.user.DontShowAgainLookup;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.util.coin.BsqFormatter;
|
||||
|
@ -53,12 +54,27 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
public class GUIUtilTest {
|
||||
|
||||
private Preferences preferences;
|
||||
private String explorerName;
|
||||
private String bsqExplorerName;
|
||||
private String txUrlPrefix;
|
||||
private String bsqTxUrlPrefix;
|
||||
private String addressUrlPrefix;
|
||||
private String bsqAddressUrlPrefix;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
GlobalSettings.setLocale(new Locale("en", "US"));
|
||||
Res.setBaseCurrencyCode("BTC");
|
||||
Res.setBaseCurrencyName("Bitcoin");
|
||||
preferences = mock(Preferences.class);
|
||||
explorerName = "Blockstream.info";
|
||||
bsqExplorerName = "mempool.space (@wiz)";
|
||||
txUrlPrefix = "https://blockstream.info/tx/";
|
||||
bsqTxUrlPrefix = "https://mempool.space/bisq/tx/";
|
||||
addressUrlPrefix = "https://blockstream.info/address/";
|
||||
bsqAddressUrlPrefix = "https://mempool.space/bisq/address/";
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -79,7 +95,6 @@ public class GUIUtilTest {
|
|||
|
||||
@Test
|
||||
public void testOpenURLWithCampaignParameters() {
|
||||
Preferences preferences = mock(Preferences.class);
|
||||
DontShowAgainLookup.setPreferences(preferences);
|
||||
GUIUtil.setPreferences(preferences);
|
||||
when(preferences.showAgain("warnOpenURLWhenTorEnabled")).thenReturn(false);
|
||||
|
@ -100,7 +115,6 @@ public class GUIUtilTest {
|
|||
|
||||
@Test
|
||||
public void testOpenURLWithoutCampaignParameters() {
|
||||
Preferences preferences = mock(Preferences.class);
|
||||
DontShowAgainLookup.setPreferences(preferences);
|
||||
GUIUtil.setPreferences(preferences);
|
||||
when(preferences.showAgain("warnOpenURLWhenTorEnabled")).thenReturn(false);
|
||||
|
@ -114,6 +128,38 @@ public class GUIUtilTest {
|
|||
*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddressUrl() {
|
||||
GUIUtil.setPreferences(preferences);
|
||||
when(preferences.getBlockChainExplorer()).thenReturn(new BlockChainExplorer(
|
||||
explorerName, txUrlPrefix, addressUrlPrefix));
|
||||
when(preferences.getBsqBlockChainExplorer()).thenReturn(new BlockChainExplorer(
|
||||
bsqExplorerName, bsqTxUrlPrefix, bsqAddressUrlPrefix));
|
||||
|
||||
String address = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
|
||||
assertEquals(addressUrlPrefix + address, GUIUtil.getAddressUrl(address));
|
||||
assertEquals(addressUrlPrefix + address, GUIUtil.getAddressUrl(address, false));
|
||||
|
||||
String bsqAddress = "B17Q6zA7LbEt5je4mtkBtYBfvDfvEwkzde";
|
||||
assertEquals(bsqAddressUrlPrefix + bsqAddress, GUIUtil.getAddressUrl(bsqAddress, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTxUrl() {
|
||||
GUIUtil.setPreferences(preferences);
|
||||
when(preferences.getBlockChainExplorer()).thenReturn(new BlockChainExplorer(
|
||||
explorerName, txUrlPrefix, addressUrlPrefix));
|
||||
when(preferences.getBsqBlockChainExplorer()).thenReturn(new BlockChainExplorer(
|
||||
bsqExplorerName, bsqTxUrlPrefix, bsqAddressUrlPrefix));
|
||||
|
||||
String txId = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
|
||||
assertEquals(txUrlPrefix + txId, GUIUtil.getTxUrl(txId));
|
||||
assertEquals(txUrlPrefix + txId, GUIUtil.getTxUrl(txId, false));
|
||||
|
||||
String bsqTxId = "4b5417ec5ab6112bedf539c3b4f5a806ed539542d8b717e1c4470aa3180edce5";
|
||||
assertEquals(bsqTxUrlPrefix + bsqTxId, GUIUtil.getTxUrl(bsqTxId, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBsqInUsd() {
|
||||
PriceFeedService priceFeedService = mock(PriceFeedService.class);
|
||||
|
|
Loading…
Add table
Reference in a new issue