Skip to content

Commit f098ece

Browse files
committed
BitcoinjBsqTests: Create per test BSQ wallet
At the moment, some tests are sharing the same BSQ wallets. This change creates a separate wallet for indenpendent tests to improve the tests's reliability.
1 parent 53467f9 commit f098ece

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

core/src/integrationTest/java/bisq/core/BitcoinjBsqTests.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ public class BitcoinjBsqTests {
5555
private final BisqRegtestNetworkParams networkParams;
5656
private PeerGroup peerGroup;
5757

58+
private RegtestWalletAppKit regtestWalletAppKit;
5859
private final Wallet btcWallet;
5960
private Wallet bsqWallet;
60-
private final Wallet secondBsqWallet;
61-
private final Wallet emptyBsqWallet;
6261

6362
private final BisqDefaultCoinSelector btcCoinSelector = new BisqDefaultCoinSelector(true) {
6463
@Override
@@ -84,14 +83,11 @@ public BitcoinjBsqTests(BitcoindRegtestSetup bitcoindRegtestSetup) {
8483

8584
var walletFactory = new WalletFactory(networkParams);
8685
btcWallet = walletFactory.createBtcWallet();
87-
secondBsqWallet = walletFactory.createBsqWallet();
88-
emptyBsqWallet = walletFactory.createBsqWallet();
8986
}
9087

9188
@BeforeAll
9289
void setup(@TempDir Path tempDir) throws InterruptedException {
93-
var wallets = List.of(btcWallet, secondBsqWallet);
94-
var regtestWalletAppKit = new RegtestWalletAppKit(networkParams, tempDir, wallets);
90+
regtestWalletAppKit = new RegtestWalletAppKit(networkParams, tempDir, List.of(btcWallet));
9591
regtestWalletAppKit.initialize();
9692

9793
WalletAppKit walletAppKit = regtestWalletAppKit.getWalletAppKit();
@@ -117,6 +113,7 @@ void sendBsqTest() throws InterruptedException, InsufficientMoneyException, BsqC
117113
bsqWallet,
118114
bsqCoinSelector);
119115

116+
Wallet secondBsqWallet = regtestWalletAppKit.createNewBsqWallet();
120117
var secondBsqWalletReceivedLatch = new CountDownLatch(1);
121118
secondBsqWallet.addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) ->
122119
secondBsqWalletReceivedLatch.countDown());
@@ -138,6 +135,7 @@ void sendBsqTest() throws InterruptedException, InsufficientMoneyException, BsqC
138135

139136
@Test
140137
void sendBsqButNotEnoughBsqTest() {
138+
Wallet emptyBsqWallet = regtestWalletAppKit.createNewBsqWallet();
141139
var bsqWalletV2 = new BsqWalletV2(networkParams,
142140
peerGroup,
143141
btcWalletV2,
@@ -164,6 +162,7 @@ void sendMoreBsqThanInWalletTest() {
164162
bsqWallet,
165163
bsqCoinSelector);
166164

165+
Wallet secondBsqWallet = regtestWalletAppKit.createNewBsqWallet();
167166
var secondBsqWalletReceivedLatch = new CountDownLatch(1);
168167
secondBsqWallet.addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) ->
169168
secondBsqWalletReceivedLatch.countDown());

0 commit comments

Comments
 (0)