mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
fix bug where the DisputeResult was not correctly deserialized.
Added ctor with all transmitted data.
This commit is contained in:
parent
d68b3e4862
commit
c6e51fdeca
4 changed files with 67 additions and 6 deletions
|
@ -421,7 +421,7 @@ message DisputeResult {
|
||||||
int64 buyer_payout_amount = 12;
|
int64 buyer_payout_amount = 12;
|
||||||
int64 seller_payout_amount = 13;
|
int64 seller_payout_amount = 13;
|
||||||
int64 arbitrator_payout_amount = 14;
|
int64 arbitrator_payout_amount = 14;
|
||||||
string arbitrator_address_asstring = 15;
|
string arbitrator_address_as_string = 15;
|
||||||
bytes arbitrator_pub_key = 16;
|
bytes arbitrator_pub_key = 16;
|
||||||
int64 close_date = 17;
|
int64 close_date = 17;
|
||||||
bool is_loser_publisher = 18;
|
bool is_loser_publisher = 18;
|
||||||
|
|
|
@ -89,8 +89,34 @@ public final class DisputeResult implements Payload {
|
||||||
public DisputeResult(String tradeId, int traderId) {
|
public DisputeResult(String tradeId, int traderId) {
|
||||||
this.tradeId = tradeId;
|
this.tradeId = tradeId;
|
||||||
this.traderId = traderId;
|
this.traderId = traderId;
|
||||||
|
this.disputeFeePolicy = DisputeFeePolicy.LOSER;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
disputeFeePolicy = DisputeFeePolicy.LOSER;
|
public DisputeResult(String tradeId, int traderId, DisputeFeePolicy disputeFeePolicy, Winner winner,
|
||||||
|
int reasonOrdinal, boolean tamperProofEvidence, boolean idVerification, boolean screenCast,
|
||||||
|
String summaryNotes, DisputeCommunicationMessage disputeCommunicationMessage,
|
||||||
|
byte[] arbitratorSignature, long buyerPayoutAmount, long sellerPayoutAmount,
|
||||||
|
long arbitratorPayoutAmount, String arbitratorAddressAsString, byte[] arbitratorPubKey,
|
||||||
|
long closeDate, boolean isLoserPublisher) {
|
||||||
|
this.tradeId = tradeId;
|
||||||
|
this.traderId = traderId;
|
||||||
|
this.disputeFeePolicy = disputeFeePolicy;
|
||||||
|
this.winner = winner;
|
||||||
|
this.reasonOrdinal = reasonOrdinal;
|
||||||
|
this.tamperProofEvidence = tamperProofEvidence;
|
||||||
|
this.idVerification = idVerification;
|
||||||
|
this.screenCast = screenCast;
|
||||||
|
this.summaryNotes = summaryNotes;
|
||||||
|
this.disputeCommunicationMessage = disputeCommunicationMessage;
|
||||||
|
this.arbitratorSignature = arbitratorSignature;
|
||||||
|
this.buyerPayoutAmount = buyerPayoutAmount;
|
||||||
|
this.sellerPayoutAmount = sellerPayoutAmount;
|
||||||
|
this.arbitratorPayoutAmount = arbitratorPayoutAmount;
|
||||||
|
this.arbitratorAddressAsString = arbitratorAddressAsString;
|
||||||
|
this.arbitratorPubKey = arbitratorPubKey;
|
||||||
|
this.closeDate = closeDate;
|
||||||
|
this.isLoserPublisher = isLoserPublisher;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +294,7 @@ public final class DisputeResult implements Payload {
|
||||||
.setBuyerPayoutAmount(buyerPayoutAmount)
|
.setBuyerPayoutAmount(buyerPayoutAmount)
|
||||||
.setSellerPayoutAmount(sellerPayoutAmount)
|
.setSellerPayoutAmount(sellerPayoutAmount)
|
||||||
.setArbitratorPayoutAmount(arbitratorPayoutAmount)
|
.setArbitratorPayoutAmount(arbitratorPayoutAmount)
|
||||||
.setArbitratorAddressAsstring(arbitratorAddressAsString)
|
.setArbitratorAddressAsString(arbitratorAddressAsString)
|
||||||
.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey))
|
.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey))
|
||||||
.setCloseDate(closeDate)
|
.setCloseDate(closeDate)
|
||||||
.setIsLoserPublisher(isLoserPublisher).build();
|
.setIsLoserPublisher(isLoserPublisher).build();
|
||||||
|
|
|
@ -247,8 +247,20 @@ public class ProtoBufferUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Message getDisputeResultMessage(Messages.DisputeResultMessage disputeResultMessage) {
|
private static Message getDisputeResultMessage(Messages.DisputeResultMessage disputeResultMessage) {
|
||||||
DisputeResult disputeResult = new DisputeResult(disputeResultMessage.getDisputeResult().getTradeId(),
|
|
||||||
disputeResultMessage.getDisputeResult().getTraderId());
|
Messages.DisputeResult disputeResultproto = disputeResultMessage.getDisputeResult();
|
||||||
|
DisputeResult disputeResult = new DisputeResult(disputeResultproto.getTradeId(),
|
||||||
|
disputeResultproto.getTraderId(), DisputeResult.DisputeFeePolicy.valueOf(disputeResultproto.getDisputeFeePolicy().name()),
|
||||||
|
DisputeResult.Winner.valueOf(disputeResultproto.getWinner().name()), disputeResultproto.getReasonOrdinal(),
|
||||||
|
disputeResultproto.getTamperProofEvidence(), disputeResultproto.getIdVerification(), disputeResultproto.getScreenCast(),
|
||||||
|
disputeResultproto.getSummaryNotes(),
|
||||||
|
(DisputeCommunicationMessage) getDisputeCommunicationMessage(disputeResultproto.getDisputeCommunicationMessage()),
|
||||||
|
disputeResultproto.getArbitratorSignature().toByteArray(), disputeResultproto.getBuyerPayoutAmount(),
|
||||||
|
disputeResultproto.getSellerPayoutAmount(), disputeResultproto.getArbitratorPayoutAmount(),
|
||||||
|
disputeResultproto.getArbitratorAddressAsString(),
|
||||||
|
disputeResultproto.getArbitratorPubKey().toByteArray(), disputeResultproto.getCloseDate(),
|
||||||
|
disputeResultproto.getIsLoserPublisher());
|
||||||
|
disputeResult.setArbitratorAddressAsString(disputeResultproto.getArbitratorAddressAsString());
|
||||||
return new DisputeResultMessage(disputeResult, getNodeAddress(disputeResultMessage.getMyNodeAddress()));
|
return new DisputeResultMessage(disputeResult, getNodeAddress(disputeResultMessage.getMyNodeAddress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +572,7 @@ public class ProtoBufferUtilities {
|
||||||
|
|
||||||
// TODO UNIT TEST THIS !!!
|
// TODO UNIT TEST THIS !!!
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Offer.Direction getDirection(Messages.Offer.Direction direction) {
|
public static Offer.Direction getDirection(Messages.Offer.Direction direction) {
|
||||||
return Offer.Direction.valueOf(direction.name());
|
return Offer.Direction.valueOf(direction.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package io.bisq.p2p.network;
|
||||||
|
|
||||||
|
import io.bisq.common.wire.proto.Messages;
|
||||||
|
import io.bisq.messages.trade.offer.payload.Offer;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 13/03/2017.
|
||||||
|
*/
|
||||||
|
public class ProtoBufferUtilitiesTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnum() {
|
||||||
|
Messages.Offer.Direction direction = Messages.Offer.Direction.SELL;
|
||||||
|
Messages.Offer.Direction direction2 = Messages.Offer.Direction.BUY;
|
||||||
|
Offer.Direction realDirection = ProtoBufferUtilities.getDirection(direction);
|
||||||
|
Offer.Direction realDirection2 = ProtoBufferUtilities.getDirection(direction2);
|
||||||
|
assertEquals("SELL", realDirection.name());
|
||||||
|
assertEquals("BUY", realDirection2.name());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue