mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-15 07:52:58 -05:00
Refactor persistence (add Storage class)
This commit is contained in:
parent
c4905baef3
commit
917dd3522b
42 changed files with 692 additions and 548 deletions
|
|
@ -36,7 +36,7 @@ public class EncryptionServiceTests {
|
|||
@Test
|
||||
public void testEncryptionWithMailboxMessage() throws Exception {
|
||||
EncryptionService<MailboxMessage> encryptionService = new EncryptionService<>();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getKeyPair();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getGeneratedRSAKeyPair();
|
||||
|
||||
TestMessage message = new TestMessage("test");
|
||||
EncryptionPackage encryptionPackage = encryptionService.encryptObject(p2pEncryptKeyPair.getPublic(), message);
|
||||
|
|
@ -47,7 +47,7 @@ public class EncryptionServiceTests {
|
|||
@Test
|
||||
public void testEncryptionWithInteger() throws Exception {
|
||||
EncryptionService<Integer> encryptionService = new EncryptionService<>();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getKeyPair();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getGeneratedRSAKeyPair();
|
||||
int data = 1234;
|
||||
EncryptionPackage encryptionPackage = encryptionService.encryptObject(p2pEncryptKeyPair.getPublic(), data);
|
||||
Integer result = encryptionService.decryptToObject(p2pEncryptKeyPair.getPrivate(), encryptionPackage);
|
||||
|
|
@ -57,7 +57,7 @@ public class EncryptionServiceTests {
|
|||
@Test
|
||||
public void testEncryptionWithBytes() throws Exception {
|
||||
EncryptionService encryptionService = new EncryptionService();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getKeyPair();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getGeneratedRSAKeyPair();
|
||||
|
||||
byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04};
|
||||
EncryptionPackage encryptionPackage = encryptionService.encrypt(p2pEncryptKeyPair.getPublic(), data);
|
||||
|
|
@ -68,7 +68,7 @@ public class EncryptionServiceTests {
|
|||
@Test
|
||||
public void testEncryptionWithLargeData() throws Exception {
|
||||
EncryptionService encryptionService = new EncryptionService();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getKeyPair();
|
||||
KeyPair p2pEncryptKeyPair = encryptionService.getGeneratedRSAKeyPair();
|
||||
|
||||
byte[] data = new byte[2000];
|
||||
new Random().nextBytes(data);
|
||||
|
|
|
|||
|
|
@ -18,26 +18,26 @@
|
|||
package io.bitsquare.trade.protocol.placeoffer;
|
||||
|
||||
import io.bitsquare.arbitration.Arbitrator;
|
||||
import io.bitsquare.fiat.FiatAccountType;
|
||||
import io.bitsquare.btc.BitcoinNetwork;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.btc.UserAgent;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.crypto.EncryptionService;
|
||||
import io.bitsquare.fiat.FiatAccountType;
|
||||
import io.bitsquare.locale.CountryUtil;
|
||||
import io.bitsquare.locale.LanguageUtil;
|
||||
import io.bitsquare.p2p.BootstrapState;
|
||||
import io.bitsquare.p2p.Node;
|
||||
import io.bitsquare.p2p.tomp2p.BootstrappedPeerBuilder;
|
||||
import io.bitsquare.p2p.tomp2p.TomP2PNode;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.offer.OfferBookService;
|
||||
import io.bitsquare.offer.tomp2p.TomP2POfferBookService;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.p2p.BootstrapState;
|
||||
import io.bitsquare.p2p.MessageService;
|
||||
import io.bitsquare.p2p.Node;
|
||||
import io.bitsquare.p2p.tomp2p.BootstrappedPeerBuilder;
|
||||
import io.bitsquare.p2p.tomp2p.TomP2PMessageService;
|
||||
import io.bitsquare.p2p.tomp2p.TomP2PNode;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
|
@ -46,6 +46,8 @@ import org.bitcoinj.utils.Threading;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Currency;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
|
@ -93,7 +95,11 @@ public class PlaceOfferProtocolTest {
|
|||
// messageService
|
||||
Node bootstrapNode = Node.at("localhost", "127.0.0.1");
|
||||
User user = new User();
|
||||
user.applyPersistedUser(null);
|
||||
/* try {
|
||||
user.initPersistedObject();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
bootstrappedPeerBuilder = new BootstrappedPeerBuilder(Node.DEFAULT_PORT, false, bootstrapNode, "<unspecified>");
|
||||
tomP2PNode = new TomP2PNode(bootstrappedPeerBuilder);
|
||||
messageService = new TomP2PMessageService(tomP2PNode, null, null, null);
|
||||
|
|
@ -119,6 +125,7 @@ public class PlaceOfferProtocolTest {
|
|||
new FeePolicy(BitcoinNetwork.REGTEST),
|
||||
null,
|
||||
persistence,
|
||||
null,
|
||||
new UserAgent("", ""),
|
||||
dir,
|
||||
"Tests"
|
||||
|
|
@ -294,9 +301,9 @@ public class PlaceOfferProtocolTest {
|
|||
faultHandler);
|
||||
}*/
|
||||
|
||||
private Offer getOffer() {
|
||||
private Offer getOffer() throws NoSuchAlgorithmException {
|
||||
return new Offer(OFFER_ID,
|
||||
DSAKeyUtil.generateDSAKeyPair().getPublic(),
|
||||
new EncryptionService().getGeneratedDSAKeyPair().getPublic(),
|
||||
Direction.BUY,
|
||||
100L,
|
||||
Coin.CENT,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue