Merge pull request #7323 from alvasw/BitcoinjBsqTests_Create_per_test_BSQ_wallet

BitcoinjBsqTests: Create per test BSQ wallet
This commit is contained in:
Alejandro García 2024-12-10 07:56:59 +00:00 committed by GitHub
commit 8ae9a39672
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -55,10 +55,9 @@ public class BitcoinjBsqTests {
private final BisqRegtestNetworkParams networkParams; private final BisqRegtestNetworkParams networkParams;
private PeerGroup peerGroup; private PeerGroup peerGroup;
private RegtestWalletAppKit regtestWalletAppKit;
private final Wallet btcWallet; private final Wallet btcWallet;
private Wallet bsqWallet; private Wallet bsqWallet;
private final Wallet secondBsqWallet;
private final Wallet emptyBsqWallet;
private final BisqDefaultCoinSelector btcCoinSelector = new BisqDefaultCoinSelector(true) { private final BisqDefaultCoinSelector btcCoinSelector = new BisqDefaultCoinSelector(true) {
@Override @Override
@ -84,14 +83,11 @@ public class BitcoinjBsqTests {
var walletFactory = new WalletFactory(networkParams); var walletFactory = new WalletFactory(networkParams);
btcWallet = walletFactory.createBtcWallet(); btcWallet = walletFactory.createBtcWallet();
secondBsqWallet = walletFactory.createBsqWallet();
emptyBsqWallet = walletFactory.createBsqWallet();
} }
@BeforeAll @BeforeAll
void setup(@TempDir Path tempDir) throws InterruptedException { void setup(@TempDir Path tempDir) throws InterruptedException {
var wallets = List.of(btcWallet, secondBsqWallet); regtestWalletAppKit = new RegtestWalletAppKit(networkParams, tempDir, List.of(btcWallet));
var regtestWalletAppKit = new RegtestWalletAppKit(networkParams, tempDir, wallets);
regtestWalletAppKit.initialize(); regtestWalletAppKit.initialize();
WalletAppKit walletAppKit = regtestWalletAppKit.getWalletAppKit(); WalletAppKit walletAppKit = regtestWalletAppKit.getWalletAppKit();
@ -117,6 +113,7 @@ public class BitcoinjBsqTests {
bsqWallet, bsqWallet,
bsqCoinSelector); bsqCoinSelector);
Wallet secondBsqWallet = regtestWalletAppKit.createNewBsqWallet();
var secondBsqWalletReceivedLatch = new CountDownLatch(1); var secondBsqWalletReceivedLatch = new CountDownLatch(1);
secondBsqWallet.addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> secondBsqWallet.addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) ->
secondBsqWalletReceivedLatch.countDown()); secondBsqWalletReceivedLatch.countDown());
@ -138,6 +135,7 @@ public class BitcoinjBsqTests {
@Test @Test
void sendBsqButNotEnoughBsqTest() { void sendBsqButNotEnoughBsqTest() {
Wallet emptyBsqWallet = regtestWalletAppKit.createNewBsqWallet();
var bsqWalletV2 = new BsqWalletV2(networkParams, var bsqWalletV2 = new BsqWalletV2(networkParams,
peerGroup, peerGroup,
btcWalletV2, btcWalletV2,
@ -164,6 +162,7 @@ public class BitcoinjBsqTests {
bsqWallet, bsqWallet,
bsqCoinSelector); bsqCoinSelector);
Wallet secondBsqWallet = regtestWalletAppKit.createNewBsqWallet();
var secondBsqWalletReceivedLatch = new CountDownLatch(1); var secondBsqWalletReceivedLatch = new CountDownLatch(1);
secondBsqWallet.addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> secondBsqWallet.addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) ->
secondBsqWalletReceivedLatch.countDown()); secondBsqWalletReceivedLatch.countDown());