Search in sources :

Example 1 with CoreProtoResolver

use of bisq.core.proto.CoreProtoResolver in project bisq-core by bisq-network.

the class UserPayloadModelVOTest method testRoundtripFull.

@Ignore("TODO InvalidKeySpecException at bisq.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
public void testRoundtripFull() {
    UserPayload vo = new UserPayload();
    vo.setAccountId("accountId");
    vo.setDisplayedAlert(new Alert("message", true, "version", new byte[] { 12, -64, 12 }, "string", null));
    vo.setDevelopersFilter(new Filter(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), false, Lists.newArrayList(), "string", new byte[] { 10, 0, 0 }, null));
    vo.setRegisteredArbitrator(ArbitratorTest.getArbitratorMock());
    vo.setRegisteredMediator(MediatorTest.getMediatorMock());
    vo.setAcceptedArbitrators(Lists.newArrayList(ArbitratorTest.getArbitratorMock()));
    vo.setAcceptedMediators(Lists.newArrayList(MediatorTest.getMediatorMock()));
    UserPayload newVo = UserPayload.fromProto(vo.toProtoMessage().getUserPayload(), new CoreProtoResolver());
}
Also used : Filter(bisq.core.filter.Filter) CoreProtoResolver(bisq.core.proto.CoreProtoResolver) Alert(bisq.core.alert.Alert) Ignore(org.junit.Ignore)

Example 2 with CoreProtoResolver

use of bisq.core.proto.CoreProtoResolver in project bisq-core by bisq-network.

the class UserPayloadModelVOTest method testRoundtrip.

@Ignore("TODO InvalidKeySpecException at bisq.common.crypto.Sig.getPublicKeyFromBytes(Sig.java:135)")
public void testRoundtrip() {
    UserPayload vo = new UserPayload();
    vo.setAccountId("accountId");
    UserPayload newVo = UserPayload.fromProto(vo.toProtoMessage().getUserPayload(), new CoreProtoResolver());
}
Also used : CoreProtoResolver(bisq.core.proto.CoreProtoResolver) Ignore(org.junit.Ignore)

Example 3 with CoreProtoResolver

use of bisq.core.proto.CoreProtoResolver in project bisq-core by bisq-network.

the class TradableList method fromProto.

@Nullable
public static TradableList fromProto(PB.TradableList proto, CoreProtoResolver coreProtoResolver, Storage<TradableList<Tradable>> storage, BtcWalletService btcWalletService) {
    log.debug("TradableList fromProto of {} ", proto);
    List<Tradable> list = proto.getTradableList().stream().map(tradable -> {
        switch(tradable.getMessageCase()) {
            case OPEN_OFFER:
                return OpenOffer.fromProto(tradable.getOpenOffer());
            case BUYER_AS_MAKER_TRADE:
                return BuyerAsMakerTrade.fromProto(tradable.getBuyerAsMakerTrade(), storage, btcWalletService, coreProtoResolver);
            case BUYER_AS_TAKER_TRADE:
                return BuyerAsTakerTrade.fromProto(tradable.getBuyerAsTakerTrade(), storage, btcWalletService, coreProtoResolver);
            case SELLER_AS_MAKER_TRADE:
                return SellerAsMakerTrade.fromProto(tradable.getSellerAsMakerTrade(), storage, btcWalletService, coreProtoResolver);
            case SELLER_AS_TAKER_TRADE:
                return SellerAsTakerTrade.fromProto(tradable.getSellerAsTakerTrade(), storage, btcWalletService, coreProtoResolver);
            default:
                log.error("Unknown messageCase. tradable.getMessageCase() = " + tradable.getMessageCase());
                throw new ProtobufferException("Unknown messageCase. tradable.getMessageCase() = " + tradable.getMessageCase());
        }
    }).collect(Collectors.toList());
    return new TradableList<>(storage, list);
}
Also used : BtcWalletService(bisq.core.btc.wallet.BtcWalletService) ProtoUtil(bisq.common.proto.ProtoUtil) PersistableEnvelope(bisq.common.proto.persistable.PersistableEnvelope) Getter(lombok.Getter) OpenOffer(bisq.core.offer.OpenOffer) FXCollections(javafx.collections.FXCollections) Collectors(java.util.stream.Collectors) ProtobufferException(bisq.common.proto.ProtobufferException) ArrayList(java.util.ArrayList) CoreProtoResolver(bisq.core.proto.CoreProtoResolver) Consumer(java.util.function.Consumer) PB(io.bisq.generated.protobuffer.PB) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) Storage(bisq.common.storage.Storage) Message(com.google.protobuf.Message) ObservableList(javafx.collections.ObservableList) Nullable(javax.annotation.Nullable) ProtobufferException(bisq.common.proto.ProtobufferException) Nullable(javax.annotation.Nullable)

Aggregations

CoreProtoResolver (bisq.core.proto.CoreProtoResolver)3 Ignore (org.junit.Ignore)2 ProtoUtil (bisq.common.proto.ProtoUtil)1 ProtobufferException (bisq.common.proto.ProtobufferException)1 PersistableEnvelope (bisq.common.proto.persistable.PersistableEnvelope)1 Storage (bisq.common.storage.Storage)1 Alert (bisq.core.alert.Alert)1 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)1 Filter (bisq.core.filter.Filter)1 OpenOffer (bisq.core.offer.OpenOffer)1 Message (com.google.protobuf.Message)1 PB (io.bisq.generated.protobuffer.PB)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 FXCollections (javafx.collections.FXCollections)1 ObservableList (javafx.collections.ObservableList)1 Nullable (javax.annotation.Nullable)1